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