-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 7733934..b8aa81c 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,399 +1,381 @@ | |||
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 | 18 | ||
19 | #include <assert.h> | 19 | #include <assert.h> |
20 | #include "manufacturers.h" | 20 | #include "manufacturers.h" |
21 | #include <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qtextstream.h> | 22 | #include <qtextstream.h> |
23 | 23 | ||
24 | #ifdef QWS | 24 | #ifdef QWS |
25 | #include <opie/odevice.h> | 25 | #include <opie/odevice.h> |
26 | using namespace Opie; | 26 | using namespace Opie; |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | 29 | ||
30 | #ifdef QWS | 30 | #ifdef QWS |
31 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
32 | #else | 32 | #else |
33 | #include "resource.h" | 33 | #include "resource.h" |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | const int col_type = 0; | 36 | const int col_type = 0; |
37 | const int col_essid = 0; | 37 | const int col_essid = 0; |
38 | const int col_sig = 1; | 38 | const int col_sig = 1; |
39 | const int col_ap = 2; | 39 | const int col_ap = 2; |
40 | const int col_channel = 3; | 40 | const int col_channel = 3; |
41 | const int col_wep = 4; | 41 | const int col_wep = 4; |
42 | const int col_traffic = 5; | 42 | const int col_traffic = 5; |
43 | const int col_manuf = 6; | 43 | const int col_manuf = 6; |
44 | const int col_firstseen = 7; | 44 | const int col_firstseen = 7; |
45 | const int col_lastseen = 8; | 45 | const int col_lastseen = 8; |
46 | 46 | ||
47 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 47 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
48 | :OListView( parent, name ), _manufacturerdb( 0 ) | 48 | :OListView( parent, name ), _manufacturerdb( 0 ) |
49 | { | 49 | { |
50 | 50 | ||
51 | setFrameShape( QListView::StyledPanel ); | 51 | setFrameShape( QListView::StyledPanel ); |
52 | setFrameShadow( QListView::Sunken ); | 52 | setFrameShadow( QListView::Sunken ); |
53 | 53 | ||
54 | addColumn( tr( "Net/Station" ) ); | 54 | addColumn( tr( "Net/Station" ) ); |
55 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); | 55 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); |
56 | addColumn( tr( "B" ) ); | 56 | addColumn( tr( "B" ) ); |
57 | setColumnAlignment( 1, AlignCenter ); | 57 | setColumnAlignment( 1, AlignCenter ); |
58 | addColumn( tr( "AP" ) ); | 58 | addColumn( tr( "AP" ) ); |
59 | setColumnAlignment( 2, AlignCenter ); | 59 | setColumnAlignment( 2, AlignCenter ); |
60 | addColumn( tr( "Chn" ) ); | 60 | addColumn( tr( "Chn" ) ); |
61 | setColumnAlignment( 3, AlignCenter ); | 61 | setColumnAlignment( 3, AlignCenter ); |
62 | addColumn( tr( "W" ) ); | 62 | addColumn( tr( "W" ) ); |
63 | setColumnAlignment( 4, AlignCenter ); | 63 | setColumnAlignment( 4, AlignCenter ); |
64 | addColumn( tr( "T" ) ); | 64 | addColumn( tr( "T" ) ); |
65 | setColumnAlignment( 5, AlignCenter ); | 65 | setColumnAlignment( 5, AlignCenter ); |
66 | addColumn( tr( "Manufacturer" ) ); | 66 | addColumn( tr( "Manufacturer" ) ); |
67 | setColumnAlignment( 6, AlignCenter ); | 67 | setColumnAlignment( 6, AlignCenter ); |
68 | addColumn( tr( "First Seen" ) ); | 68 | addColumn( tr( "First Seen" ) ); |
69 | setColumnAlignment( 7, AlignCenter ); | 69 | setColumnAlignment( 7, AlignCenter ); |
70 | addColumn( tr( "Last Seen" ) ); | 70 | addColumn( tr( "Last Seen" ) ); |
71 | setColumnAlignment( 8, AlignCenter ); | 71 | setColumnAlignment( 8, AlignCenter ); |
72 | setRootIsDecorated( true ); | 72 | setRootIsDecorated( true ); |
73 | setAllColumnsShowFocus( true ); | 73 | setAllColumnsShowFocus( true ); |
74 | }; | 74 | }; |
75 | 75 | ||
76 | MScanListView::~MScanListView() | 76 | MScanListView::~MScanListView() |
77 | { | 77 | { |
78 | }; | 78 | }; |
79 | 79 | ||
80 | OListViewItem* MScanListView::childFactory() | 80 | OListViewItem* MScanListView::childFactory() |
81 | { | 81 | { |
82 | return new MScanListItem( this ); | 82 | return new MScanListItem( this ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void MScanListView::serializeTo( QDataStream& s) const | 85 | void MScanListView::serializeTo( QDataStream& s) const |
86 | { | 86 | { |
87 | qDebug( "serializing MScanListView" ); | 87 | qDebug( "serializing MScanListView" ); |
88 | OListView::serializeTo( s ); | 88 | OListView::serializeTo( s ); |
89 | } | 89 | } |
90 | 90 | ||
91 | void MScanListView::serializeFrom( QDataStream& s) | 91 | void MScanListView::serializeFrom( QDataStream& s) |
92 | { | 92 | { |
93 | qDebug( "serializing MScanListView" ); | 93 | qDebug( "serializing MScanListView" ); |
94 | OListView::serializeFrom( s ); | 94 | OListView::serializeFrom( s ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) | 97 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) |
98 | { | 98 | { |
99 | _manufacturerdb = manufacturerdb; | 99 | _manufacturerdb = manufacturerdb; |
100 | } | 100 | } |
101 | 101 | ||
102 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 102 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
103 | { | 103 | { |
104 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | 104 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) |
105 | 105 | ||
106 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", | 106 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", |
107 | (const char*) type, | 107 | (const char*) type, |
108 | (const char*) essid, | 108 | (const char*) essid, |
109 | (const char*) macaddr, | 109 | (const char*) macaddr, |
110 | channel ); | 110 | channel ); |
111 | 111 | ||
112 | // search, if we already have seen this net | 112 | // search, if we already have seen this net |
113 | 113 | ||
114 | QString s; | 114 | QString s; |
115 | MScanListItem* network; | 115 | MScanListItem* network; |
116 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 116 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
117 | 117 | ||
118 | while ( item && ( item->text( 0 ) != essid ) ) | 118 | while ( item && ( item->text( col_essid ) != essid ) ) |
119 | { | 119 | { |
120 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | 120 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
121 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 121 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
122 | } | 122 | } |
123 | if ( item ) | 123 | if ( item ) |
124 | { | 124 | { |
125 | // animate the item | ||
126 | |||
127 | /* | ||
128 | |||
129 | const QPixmap* pixmap = item->pixmap( 0 ); | ||
130 | const QPixmap* nextpixmap = ani2; | ||
131 | if ( pixmap == ani1 ) | ||
132 | nextpixmap = ani2; | ||
133 | else if ( pixmap == ani2 ) | ||
134 | nextpixmap = ani3; | ||
135 | else if ( pixmap == ani3 ) | ||
136 | nextpixmap = ani4; | ||
137 | else if ( pixmap == ani4 ) | ||
138 | nextpixmap = ani1; | ||
139 | item->setPixmap( 0, *nextpixmap ); */ | ||
140 | |||
141 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | ||
142 | |||
143 | // we have already seen this net, check all childs if MAC exists | 125 | // we have already seen this net, check all childs if MAC exists |
144 | 126 | ||
145 | network = item; | 127 | network = item; |
146 | 128 | ||
147 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 129 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
148 | assert( item ); // this shouldn't fail | 130 | assert( item ); // this shouldn't fail |
149 | 131 | ||
150 | while ( item && ( item->text( 2 ) != macaddr ) ) | 132 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
151 | { | 133 | { |
152 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | 134 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
153 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 135 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
154 | } | 136 | } |
155 | 137 | ||
156 | if ( item ) | 138 | if ( item ) |
157 | { | 139 | { |
158 | // we have already seen this item, it's a dupe | 140 | // we have already seen this item, it's a dupe |
159 | #ifdef DEBUG | 141 | #ifdef DEBUG |
160 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 142 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
161 | #endif | 143 | #endif |
162 | item->receivedBeacon(); | 144 | item->receivedBeacon(); |
163 | return; | 145 | return; |
164 | } | 146 | } |
165 | } | 147 | } |
166 | else | 148 | else |
167 | { | 149 | { |
168 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | 150 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); |
169 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 151 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
170 | } | 152 | } |
171 | 153 | ||
172 | 154 | ||
173 | // insert new station as child from network | 155 | // insert new station as child from network |
174 | 156 | ||
175 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 157 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
176 | 158 | ||
177 | qDebug( "inserting new station %s", (const char*) macaddr ); | 159 | qDebug( "inserting new station %s", (const char*) macaddr ); |
178 | 160 | ||
179 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 161 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
180 | if ( _manufacturerdb ) | 162 | if ( _manufacturerdb ) |
181 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); | 163 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); |
182 | 164 | ||
183 | if ( type == "managed" ) | 165 | if ( type == "managed" ) |
184 | { | 166 | { |
185 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | 167 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); |
186 | } | 168 | } |
187 | else | 169 | else |
188 | { | 170 | { |
189 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | 171 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); |
190 | } | 172 | } |
191 | 173 | ||
192 | } | 174 | } |
193 | 175 | ||
194 | 176 | ||
195 | void MScanListView::addIfNotExisting( MScanListItem* network, QString addr ) | 177 | void MScanListView::addIfNotExisting( MScanListItem* network, QString addr ) |
196 | { | 178 | { |
197 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 179 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
198 | 180 | ||
199 | while ( subitem && ( subitem->text( col_ap ) != addr ) ) | 181 | while ( subitem && ( subitem->text( col_ap ) != addr ) ) |
200 | { | 182 | { |
201 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 183 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
202 | subitem = static_cast<MScanListItem*> ( subitem->itemBelow() ); | 184 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
203 | } | 185 | } |
204 | 186 | ||
205 | if ( subitem ) | 187 | if ( subitem ) |
206 | { | 188 | { |
207 | // we have already seen this item, it's a dupe | 189 | // we have already seen this item, it's a dupe |
208 | #ifdef DEBUG | 190 | #ifdef DEBUG |
209 | qDebug( "%s is a dupe - ignoring...", (const char*) addr ); | 191 | qDebug( "%s is a dupe - ignoring...", (const char*) addr ); |
210 | #endif | 192 | #endif |
211 | subitem->receivedBeacon(); //FIXME: sent data bit | 193 | subitem->receivedBeacon(); //FIXME: sent data bit |
212 | return; | 194 | return; |
213 | } | 195 | } |
214 | 196 | ||
215 | // Hey, it seems to be a new item :-D | 197 | // Hey, it seems to be a new item :-D |
216 | MScanListItem* station = new MScanListItem( network, "station", /* network->text( col_essid ) */ "", addr, false, -1, -1 ); | 198 | MScanListItem* station = new MScanListItem( network, "station", /* network->text( col_essid ) */ "", addr, false, -1, -1 ); |
217 | if ( _manufacturerdb ) | 199 | if ( _manufacturerdb ) |
218 | station->setManufacturer( _manufacturerdb->lookup( addr ) ); | 200 | station->setManufacturer( _manufacturerdb->lookup( addr ) ); |
219 | } | 201 | } |
220 | 202 | ||
221 | 203 | ||
222 | void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) | 204 | void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) |
223 | { | 205 | { |
224 | QString s; | 206 | QString s; |
225 | MScanListItem* network; | 207 | MScanListItem* network; |
226 | 208 | ||
227 | QListViewItemIterator it( this ); | 209 | QListViewItemIterator it( this ); |
228 | while ( it.current() && | 210 | while ( it.current() && |
229 | it.current()->text( col_ap ) != viaFrom && | 211 | it.current()->text( col_ap ) != viaFrom && |
230 | it.current()->text( col_ap ) != viaTo ) ++it; | 212 | it.current()->text( col_ap ) != viaTo ) ++it; |
231 | 213 | ||
232 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 214 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
233 | 215 | ||
234 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 216 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
235 | { | 217 | { |
236 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 218 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
237 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 219 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
238 | } | 220 | } |
239 | else | 221 | else |
240 | { | 222 | { |
241 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 223 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
242 | } | 224 | } |
243 | } | 225 | } |
244 | 226 | ||
245 | 227 | ||
246 | void MScanListView::toDStraffic( QString from, QString to, QString via ) | 228 | void MScanListView::toDStraffic( QString from, QString to, QString via ) |
247 | { | 229 | { |
248 | QString s; | 230 | QString s; |
249 | MScanListItem* network; | 231 | MScanListItem* network; |
250 | 232 | ||
251 | QListViewItemIterator it( this ); | 233 | QListViewItemIterator it( this ); |
252 | while ( it.current() && it.current()->text( col_ap ) != via ) ++it; | 234 | while ( it.current() && it.current()->text( col_ap ) != via ) ++it; |
253 | 235 | ||
254 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 236 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
255 | 237 | ||
256 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 238 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
257 | { | 239 | { |
258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 240 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
259 | } | 241 | } |
260 | else | 242 | else |
261 | { | 243 | { |
262 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 244 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
263 | } | 245 | } |
264 | } | 246 | } |
265 | 247 | ||
266 | void MScanListView::fromDStraffic( QString from, QString to, QString via ) | 248 | void MScanListView::fromDStraffic( QString from, QString to, QString via ) |
267 | { | 249 | { |
268 | qWarning( "D'oh! Not yet implemented..." ); | 250 | qWarning( "D'oh! Not yet implemented..." ); |
269 | } | 251 | } |
270 | 252 | ||
271 | void MScanListView::IBSStraffic( QString from, QString to, QString via ) | 253 | void MScanListView::IBSStraffic( QString from, QString to, QString via ) |
272 | { | 254 | { |
273 | qWarning( "D'oh! Not yet implemented..." ); | 255 | qWarning( "D'oh! Not yet implemented..." ); |
274 | } | 256 | } |
275 | 257 | ||
276 | //============================================================ | 258 | //============================================================ |
277 | // MScanListItem | 259 | // MScanListItem |
278 | //============================================================ | 260 | //============================================================ |
279 | 261 | ||
280 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 262 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
281 | bool wep, int channel, int signal ) | 263 | bool wep, int channel, int signal ) |
282 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 264 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
283 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 265 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
284 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 266 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
285 | { | 267 | { |
286 | qDebug( "creating scanlist item" ); | 268 | qDebug( "creating scanlist item" ); |
287 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 269 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
288 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 270 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
289 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 271 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
290 | } | 272 | } |
291 | 273 | ||
292 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 274 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
293 | bool wep, int channel, int signal ) | 275 | bool wep, int channel, int signal ) |
294 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 276 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
295 | { | 277 | { |
296 | qDebug( "creating scanlist item" ); | 278 | qDebug( "creating scanlist item" ); |
297 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 279 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
298 | } | 280 | } |
299 | 281 | ||
300 | OListViewItem* MScanListItem::childFactory() | 282 | OListViewItem* MScanListItem::childFactory() |
301 | { | 283 | { |
302 | return new MScanListItem( this ); | 284 | return new MScanListItem( this ); |
303 | } | 285 | } |
304 | 286 | ||
305 | void MScanListItem::serializeTo( QDataStream& s ) const | 287 | void MScanListItem::serializeTo( QDataStream& s ) const |
306 | { | 288 | { |
307 | qDebug( "serializing MScanListItem" ); | 289 | qDebug( "serializing MScanListItem" ); |
308 | OListViewItem::serializeTo( s ); | 290 | OListViewItem::serializeTo( s ); |
309 | 291 | ||
310 | s << _type; | 292 | s << _type; |
311 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 293 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
312 | } | 294 | } |
313 | 295 | ||
314 | void MScanListItem::serializeFrom( QDataStream& s ) | 296 | void MScanListItem::serializeFrom( QDataStream& s ) |
315 | { | 297 | { |
316 | qDebug( "serializing MScanListItem" ); | 298 | qDebug( "serializing MScanListItem" ); |
317 | OListViewItem::serializeFrom( s ); | 299 | OListViewItem::serializeFrom( s ); |
318 | 300 | ||
319 | char wep; | 301 | char wep; |
320 | s >> _type; | 302 | s >> _type; |
321 | s >> (Q_UINT8) wep; | 303 | s >> (Q_UINT8) wep; |
322 | _wep = (wep == 'y'); | 304 | _wep = (wep == 'y'); |
323 | 305 | ||
324 | QString name; | 306 | QString name; |
325 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 307 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
326 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 308 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
327 | if ( _wep ) | 309 | if ( _wep ) |
328 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 310 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
329 | listView()->triggerUpdate(); | 311 | listView()->triggerUpdate(); |
330 | } | 312 | } |
331 | 313 | ||
332 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 314 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
333 | { | 315 | { |
334 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 316 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
335 | (const char*) type, | 317 | (const char*) type, |
336 | (const char*) essid, | 318 | (const char*) essid, |
337 | (const char*) macaddr, | 319 | (const char*) macaddr, |
338 | channel ); | 320 | channel ); |
339 | 321 | ||
340 | // set icon for managed or adhoc mode | 322 | // set icon for managed or adhoc mode |
341 | QString name; | 323 | QString name; |
342 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 324 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
343 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 325 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
344 | 326 | ||
345 | // set icon for wep (wireless encryption protocol) | 327 | // set icon for wep (wireless encryption protocol) |
346 | if ( wep ) | 328 | if ( wep ) |
347 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 329 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
348 | 330 | ||
349 | // set channel and signal text | 331 | // set channel and signal text |
350 | 332 | ||
351 | if ( signal != -1 ) | 333 | if ( signal != -1 ) |
352 | setText( col_sig, QString::number( signal ) ); | 334 | setText( col_sig, QString::number( signal ) ); |
353 | if ( channel != -1 ) | 335 | if ( channel != -1 ) |
354 | setText( col_channel, QString::number( channel ) ); | 336 | setText( col_channel, QString::number( channel ) ); |
355 | 337 | ||
356 | setText( col_firstseen, QTime::currentTime().toString() ); | 338 | setText( col_firstseen, QTime::currentTime().toString() ); |
357 | //setText( col_lastseen, QTime::currentTime().toString() ); | 339 | //setText( col_lastseen, QTime::currentTime().toString() ); |
358 | 340 | ||
359 | listView()->triggerUpdate(); | 341 | listView()->triggerUpdate(); |
360 | 342 | ||
361 | this->type = type; | 343 | this->type = type; |
362 | _type = type; | 344 | _type = type; |
363 | _essid = essid; | 345 | _essid = essid; |
364 | _macaddr = macaddr; | 346 | _macaddr = macaddr; |
365 | _channel = channel; | 347 | _channel = channel; |
366 | _beacons = 1; | 348 | _beacons = 1; |
367 | _signal = 0; | 349 | _signal = 0; |
368 | } | 350 | } |
369 | 351 | ||
370 | 352 | ||
371 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 353 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
372 | { | 354 | { |
373 | setText( col_manuf, manufacturer ); | 355 | setText( col_manuf, manufacturer ); |
374 | } | 356 | } |
375 | 357 | ||
376 | 358 | ||
377 | void MScanListItem::playSound( const QString& sound ) const | 359 | void MScanListItem::playSound( const QString& sound ) const |
378 | { | 360 | { |
379 | #ifdef QWS | 361 | #ifdef QWS |
380 | if ( sound == "Ignore" ) return; | 362 | if ( sound == "Ignore" ) return; |
381 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 363 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
382 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 364 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
383 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 365 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
384 | #endif | 366 | #endif |
385 | } | 367 | } |
386 | 368 | ||
387 | 369 | ||
388 | void MScanListItem::receivedBeacon() | 370 | void MScanListItem::receivedBeacon() |
389 | { | 371 | { |
390 | _beacons++; | 372 | _beacons++; |
391 | #ifdef DEBUG | 373 | #ifdef DEBUG |
392 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 374 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
393 | #endif | 375 | #endif |
394 | setText( col_sig, QString::number( _beacons ) ); | 376 | setText( col_sig, QString::number( _beacons ) ); |
395 | setText( col_lastseen, QTime::currentTime().toString() ); | 377 | setText( col_lastseen, QTime::currentTime().toString() ); |
396 | if ( WellenreiterConfigWindow::instance() ) | 378 | if ( WellenreiterConfigWindow::instance() ) |
397 | playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); | 379 | playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); |
398 | } | 380 | } |
399 | 381 | ||