-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1525934..1ef24d2 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,363 +1,365 @@ | |||
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( 0 ) != essid ) ) |
119 | { | 119 | { |
120 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | 120 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); |
121 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 121 | item = static_cast<MScanListItem*> ( item->itemBelow() ); |
122 | } | 122 | } |
123 | if ( item ) | 123 | if ( item ) |
124 | { | 124 | { |
125 | // animate the item | 125 | // animate the item |
126 | 126 | ||
127 | /* | 127 | /* |
128 | 128 | ||
129 | const QPixmap* pixmap = item->pixmap( 0 ); | 129 | const QPixmap* pixmap = item->pixmap( 0 ); |
130 | const QPixmap* nextpixmap = ani2; | 130 | const QPixmap* nextpixmap = ani2; |
131 | if ( pixmap == ani1 ) | 131 | if ( pixmap == ani1 ) |
132 | nextpixmap = ani2; | 132 | nextpixmap = ani2; |
133 | else if ( pixmap == ani2 ) | 133 | else if ( pixmap == ani2 ) |
134 | nextpixmap = ani3; | 134 | nextpixmap = ani3; |
135 | else if ( pixmap == ani3 ) | 135 | else if ( pixmap == ani3 ) |
136 | nextpixmap = ani4; | 136 | nextpixmap = ani4; |
137 | else if ( pixmap == ani4 ) | 137 | else if ( pixmap == ani4 ) |
138 | nextpixmap = ani1; | 138 | nextpixmap = ani1; |
139 | item->setPixmap( 0, *nextpixmap ); */ | 139 | item->setPixmap( 0, *nextpixmap ); */ |
140 | 140 | ||
141 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | 141 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); |
142 | 142 | ||
143 | // we have already seen this net, check all childs if MAC exists | 143 | // we have already seen this net, check all childs if MAC exists |
144 | 144 | ||
145 | network = item; | 145 | network = item; |
146 | 146 | ||
147 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 147 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
148 | assert( item ); // this shouldn't fail | 148 | assert( item ); // this shouldn't fail |
149 | 149 | ||
150 | while ( item && ( item->text( 2 ) != macaddr ) ) | 150 | while ( item && ( item->text( 2 ) != macaddr ) ) |
151 | { | 151 | { |
152 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | 152 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); |
153 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 153 | item = static_cast<MScanListItem*> ( item->itemBelow() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | if ( item ) | 156 | if ( item ) |
157 | { | 157 | { |
158 | // we have already seen this item, it's a dupe | 158 | // we have already seen this item, it's a dupe |
159 | #ifdef DEBUG | 159 | #ifdef DEBUG |
160 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 160 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
161 | #endif | 161 | #endif |
162 | item->receivedBeacon(); | 162 | item->receivedBeacon(); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | 168 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); |
169 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); | 169 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | // insert new station as child from network | 173 | // insert new station as child from network |
174 | 174 | ||
175 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 175 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
176 | 176 | ||
177 | qDebug( "inserting new station %s", (const char*) macaddr ); | 177 | qDebug( "inserting new station %s", (const char*) macaddr ); |
178 | 178 | ||
179 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 179 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
180 | if ( _manufacturerdb ) | 180 | if ( _manufacturerdb ) |
181 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); | 181 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); |
182 | 182 | ||
183 | if ( type == "managed" ) | 183 | if ( type == "managed" ) |
184 | { | 184 | { |
185 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | 185 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); |
186 | } | 186 | } |
187 | else | 187 | else |
188 | { | 188 | { |
189 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | 189 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); |
190 | } | 190 | } |
191 | 191 | ||
192 | } | 192 | } |
193 | 193 | ||
194 | void MScanListView::traffic( QString type, QString from, QString to, QString via, QString additional ) | 194 | void MScanListView::traffic( QString type, QString from, QString to, QString via, QString additional ) |
195 | { | 195 | { |
196 | if ( type != "toDS" ) return; | 196 | if ( type != "toDS" ) return; |
197 | 197 | ||
198 | qDebug( "MScanList::traffic( [%s] | %s -> %s (via %s)", | 198 | qDebug( "MScanList::traffic( [%s] | %s -> %s (via %s)", |
199 | (const char*) type, (const char*) from, | 199 | (const char*) type, (const char*) from, |
200 | (const char*) to, (const char*) via ); | 200 | (const char*) to, (const char*) via ); |
201 | 201 | ||
202 | QString s; | 202 | QString s; |
203 | MScanListItem* network; | 203 | MScanListItem* network; |
204 | 204 | ||
205 | QListViewItemIterator it( this ); | 205 | QListViewItemIterator it( this ); |
206 | while ( it.current() && it.current()->text( col_ap ) != via ) ++it; | 206 | while ( it.current() && it.current()->text( col_ap ) != via ) ++it; |
207 | 207 | ||
208 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 208 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
209 | 209 | ||
210 | if ( item ) // AP has been shown up, so just add our new "from" - station | 210 | if ( item ) // AP has been shown up, so just add our new "from" - station |
211 | { | 211 | { |
212 | network = static_cast<MScanListItem*>( item->parent() ); | 212 | network = static_cast<MScanListItem*>( item->parent() ); |
213 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 213 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
214 | 214 | ||
215 | while ( subitem && ( subitem->text( col_ap ) != from ) ) | 215 | while ( subitem && ( subitem->text( col_ap ) != from ) ) |
216 | { | 216 | { |
217 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 217 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
218 | subitem = static_cast<MScanListItem*> ( subitem->itemBelow() ); | 218 | subitem = static_cast<MScanListItem*> ( subitem->itemBelow() ); |
219 | } | 219 | } |
220 | 220 | ||
221 | if ( subitem ) | 221 | if ( subitem ) |
222 | { | 222 | { |
223 | // we have already seen this item, it's a dupe | 223 | // we have already seen this item, it's a dupe |
224 | #ifdef DEBUG | 224 | #ifdef DEBUG |
225 | qDebug( "%s is a dupe - ignoring...", (const char*) from ); | 225 | qDebug( "%s is a dupe - ignoring...", (const char*) from ); |
226 | #endif | 226 | #endif |
227 | subitem->receivedBeacon(); //FIXME: sent data bit | 227 | subitem->receivedBeacon(); //FIXME: sent data bit |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | // Hey, it seems to be a new item :-D | 231 | // Hey, it seems to be a new item :-D |
232 | MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 ); | 232 | MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 ); |
233 | if ( _manufacturerdb ) | 233 | if ( _manufacturerdb ) |
234 | station->setManufacturer( _manufacturerdb->lookup( from ) ); | 234 | station->setManufacturer( _manufacturerdb->lookup( from ) ); |
235 | } | 235 | } |
236 | else | 236 | else |
237 | { | 237 | { |
238 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); | 238 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | //============================================================ | 242 | //============================================================ |
243 | // MScanListItem | 243 | // MScanListItem |
244 | //============================================================ | 244 | //============================================================ |
245 | 245 | ||
246 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 246 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
247 | bool wep, int channel, int signal ) | 247 | bool wep, int channel, int signal ) |
248 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 248 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
249 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 249 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
250 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 250 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
251 | { | 251 | { |
252 | qDebug( "creating scanlist item" ); | 252 | qDebug( "creating scanlist item" ); |
253 | if ( WellenreiterConfigWindow::instance() && type == "networks" ) | 253 | if ( WellenreiterConfigWindow::instance() && type == "networks" ) |
254 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 254 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
255 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 255 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
256 | } | 256 | } |
257 | 257 | ||
258 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 258 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
259 | bool wep, int channel, int signal ) | 259 | bool wep, int channel, int signal ) |
260 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 260 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
261 | { | 261 | { |
262 | qDebug( "creating scanlist item" ); | 262 | qDebug( "creating scanlist item" ); |
263 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 263 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
264 | } | 264 | } |
265 | 265 | ||
266 | OListViewItem* MScanListItem::childFactory() | 266 | OListViewItem* MScanListItem::childFactory() |
267 | { | 267 | { |
268 | return new MScanListItem( this ); | 268 | return new MScanListItem( this ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void MScanListItem::serializeTo( QDataStream& s ) const | 271 | void MScanListItem::serializeTo( QDataStream& s ) const |
272 | { | 272 | { |
273 | qDebug( "serializing MScanListItem" ); | 273 | qDebug( "serializing MScanListItem" ); |
274 | OListViewItem::serializeTo( s ); | 274 | OListViewItem::serializeTo( s ); |
275 | 275 | ||
276 | s << _type; | 276 | s << _type; |
277 | s << (Q_UINT8) _wep; | 277 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void MScanListItem::serializeFrom( QDataStream& s ) | 280 | void MScanListItem::serializeFrom( QDataStream& s ) |
281 | { | 281 | { |
282 | qDebug( "serializing MScanListItem" ); | 282 | qDebug( "serializing MScanListItem" ); |
283 | OListViewItem::serializeFrom( s ); | 283 | OListViewItem::serializeFrom( s ); |
284 | 284 | ||
285 | char wep; | ||
285 | s >> _type; | 286 | s >> _type; |
286 | s >> (Q_UINT8) _wep; | 287 | s >> (Q_UINT8) wep; |
288 | _wep = (wep == 'y'); | ||
287 | 289 | ||
288 | QString name; | 290 | QString name; |
289 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 291 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
290 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 292 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
291 | if ( _wep ) | 293 | if ( _wep ) |
292 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 294 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
293 | listView()->triggerUpdate(); | 295 | listView()->triggerUpdate(); |
294 | } | 296 | } |
295 | 297 | ||
296 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 298 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
297 | { | 299 | { |
298 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 300 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
299 | (const char*) type, | 301 | (const char*) type, |
300 | (const char*) essid, | 302 | (const char*) essid, |
301 | (const char*) macaddr, | 303 | (const char*) macaddr, |
302 | channel ); | 304 | channel ); |
303 | 305 | ||
304 | // set icon for managed or adhoc mode | 306 | // set icon for managed or adhoc mode |
305 | QString name; | 307 | QString name; |
306 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 308 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
307 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 309 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
308 | 310 | ||
309 | // set icon for wep (wireless encryption protocol) | 311 | // set icon for wep (wireless encryption protocol) |
310 | if ( wep ) | 312 | if ( wep ) |
311 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 313 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
312 | 314 | ||
313 | // set channel and signal text | 315 | // set channel and signal text |
314 | 316 | ||
315 | if ( signal != -1 ) | 317 | if ( signal != -1 ) |
316 | setText( col_sig, QString::number( signal ) ); | 318 | setText( col_sig, QString::number( signal ) ); |
317 | if ( channel != -1 ) | 319 | if ( channel != -1 ) |
318 | setText( col_channel, QString::number( channel ) ); | 320 | setText( col_channel, QString::number( channel ) ); |
319 | 321 | ||
320 | setText( col_firstseen, QTime::currentTime().toString() ); | 322 | setText( col_firstseen, QTime::currentTime().toString() ); |
321 | //setText( col_lastseen, QTime::currentTime().toString() ); | 323 | //setText( col_lastseen, QTime::currentTime().toString() ); |
322 | 324 | ||
323 | listView()->triggerUpdate(); | 325 | listView()->triggerUpdate(); |
324 | 326 | ||
325 | this->type = type; | 327 | this->type = type; |
326 | _type = type; | 328 | _type = type; |
327 | _essid = essid; | 329 | _essid = essid; |
328 | _macaddr = macaddr; | 330 | _macaddr = macaddr; |
329 | _channel = channel; | 331 | _channel = channel; |
330 | _beacons = 1; | 332 | _beacons = 1; |
331 | _signal = 0; | 333 | _signal = 0; |
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
335 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 337 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
336 | { | 338 | { |
337 | setText( col_manuf, manufacturer ); | 339 | setText( col_manuf, manufacturer ); |
338 | } | 340 | } |
339 | 341 | ||
340 | 342 | ||
341 | void MScanListItem::playSound( const QString& sound ) const | 343 | void MScanListItem::playSound( const QString& sound ) const |
342 | { | 344 | { |
343 | #ifdef QWS | 345 | #ifdef QWS |
344 | if ( sound == "Ignore" ) return; | 346 | if ( sound == "Ignore" ) return; |
345 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 347 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
346 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 348 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
347 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 349 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
348 | #endif | 350 | #endif |
349 | } | 351 | } |
350 | 352 | ||
351 | 353 | ||
352 | void MScanListItem::receivedBeacon() | 354 | void MScanListItem::receivedBeacon() |
353 | { | 355 | { |
354 | _beacons++; | 356 | _beacons++; |
355 | #ifdef DEBUG | 357 | #ifdef DEBUG |
356 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 358 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
357 | #endif | 359 | #endif |
358 | setText( col_sig, QString::number( _beacons ) ); | 360 | setText( col_sig, QString::number( _beacons ) ); |
359 | setText( col_lastseen, QTime::currentTime().toString() ); | 361 | setText( col_lastseen, QTime::currentTime().toString() ); |
360 | if ( WellenreiterConfigWindow::instance() ) | 362 | if ( WellenreiterConfigWindow::instance() ) |
361 | playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); | 363 | playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); |
362 | } | 364 | } |
363 | 365 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 8d18f73..8c2c315 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,285 +1,294 @@ | |||
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 | // Opie | 16 | // Opie |
17 | 17 | ||
18 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <opie/odevice.h> | 19 | #include <opie/odevice.h> |
20 | using namespace Opie; | 20 | using namespace Opie; |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #ifdef QWS | 23 | #ifdef QWS |
24 | #include <opie2/oapplication.h> | 24 | #include <opie2/oapplication.h> |
25 | #else | 25 | #else |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #endif | 27 | #endif |
28 | #include <opie2/onetwork.h> | 28 | #include <opie2/onetwork.h> |
29 | #include <opie2/opcap.h> | 29 | #include <opie2/opcap.h> |
30 | 30 | ||
31 | // Qt | 31 | // Qt |
32 | 32 | ||
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qsocketnotifier.h> | 37 | #include <qsocketnotifier.h> |
38 | 38 | ||
39 | // Standard | 39 | // Standard |
40 | 40 | ||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | #include <errno.h> | 42 | #include <errno.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <string.h> | 44 | #include <string.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | 47 | ||
48 | // Local | 48 | // Local |
49 | 49 | ||
50 | #include "wellenreiter.h" | 50 | #include "wellenreiter.h" |
51 | #include "scanlist.h" | 51 | #include "scanlist.h" |
52 | #include "logwindow.h" | 52 | #include "logwindow.h" |
53 | #include "hexwindow.h" | 53 | #include "hexwindow.h" |
54 | #include "configwindow.h" | 54 | #include "configwindow.h" |
55 | 55 | ||
56 | #include "manufacturers.h" | 56 | #include "manufacturers.h" |
57 | 57 | ||
58 | Wellenreiter::Wellenreiter( QWidget* parent ) | 58 | Wellenreiter::Wellenreiter( QWidget* parent ) |
59 | : WellenreiterBase( parent, 0, 0 ), | 59 | : WellenreiterBase( parent, 0, 0 ), |
60 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) | 60 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) |
61 | { | 61 | { |
62 | 62 | ||
63 | // | 63 | // |
64 | // construct manufacturer database | 64 | // construct manufacturer database |
65 | // | 65 | // |
66 | 66 | ||
67 | QString manufile; | 67 | QString manufile; |
68 | #ifdef QWS | 68 | #ifdef QWS |
69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
70 | #else | 70 | #else |
71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
72 | #endif | 72 | #endif |
73 | manufacturerdb = new ManufacturerDB( manufile ); | 73 | manufacturerdb = new ManufacturerDB( manufile ); |
74 | 74 | ||
75 | logwindow->log( "(i) Wellenreiter has been started." ); | 75 | logwindow->log( "(i) Wellenreiter has been started." ); |
76 | 76 | ||
77 | // | 77 | // |
78 | // detect operating system | 78 | // detect operating system |
79 | // | 79 | // |
80 | 80 | ||
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | QString sys; | 82 | QString sys; |
83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
84 | _system = ODevice::inst()->system(); | 84 | _system = ODevice::inst()->system(); |
85 | logwindow->log( sys ); | 85 | logwindow->log( sys ); |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | // setup GUI | 88 | // setup GUI |
89 | netview->setColumnWidthMode( 1, QListView::Manual ); | 89 | netview->setColumnWidthMode( 1, QListView::Manual ); |
90 | 90 | ||
91 | if ( manufacturerdb ) | 91 | if ( manufacturerdb ) |
92 | netview->setManufacturerDB( manufacturerdb ); | 92 | netview->setManufacturerDB( manufacturerdb ); |
93 | 93 | ||
94 | pcap = new OPacketCapturer(); | 94 | pcap = new OPacketCapturer(); |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | Wellenreiter::~Wellenreiter() | 98 | Wellenreiter::~Wellenreiter() |
99 | { | 99 | { |
100 | // no need to delete child widgets, Qt does it all for us | 100 | // no need to delete child widgets, Qt does it all for us |
101 | 101 | ||
102 | delete manufacturerdb; | 102 | delete manufacturerdb; |
103 | delete pcap; | 103 | delete pcap; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 107 | { |
108 | configwindow = cw; | 108 | configwindow = cw; |
109 | } | 109 | } |
110 | 110 | ||
111 | void Wellenreiter::receivePacket(OPacket* p) | 111 | void Wellenreiter::receivePacket(OPacket* p) |
112 | { | 112 | { |
113 | hexWindow()->log( p->dump( 8 ) ); | 113 | hexWindow()->log( p->dump( 8 ) ); |
114 | 114 | ||
115 | // check if we received a beacon frame | 115 | // check if we received a beacon frame |
116 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 116 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
117 | if ( beacon ) | 117 | if ( beacon && beacon->managementType() == "Beacon" ) |
118 | { | 118 | { |
119 | QString type; | 119 | QString type; |
120 | if ( beacon->canIBSS() ) | 120 | if ( beacon->canIBSS() ) |
121 | { | ||
121 | type = "adhoc"; | 122 | type = "adhoc"; |
122 | else | 123 | } |
124 | else if ( beacon->canESS() ) | ||
125 | { | ||
123 | type = "managed"; | 126 | type = "managed"; |
127 | } | ||
128 | else | ||
129 | { | ||
130 | qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); | ||
131 | return; | ||
132 | } | ||
124 | 133 | ||
125 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 134 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
126 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 135 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
127 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 136 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
128 | int channel = ds ? ds->channel() : -1; | 137 | int channel = ds ? ds->channel() : -1; |
129 | 138 | ||
130 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 139 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
131 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); | 140 | netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); |
132 | return; | 141 | return; |
133 | } | 142 | } |
134 | 143 | ||
135 | // check for a data frame | 144 | // check for a data frame |
136 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); | 145 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); |
137 | if ( data ) | 146 | if ( data ) |
138 | { | 147 | { |
139 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 148 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
140 | if ( wlan->fromDS() && !wlan->toDS() ) | 149 | if ( wlan->fromDS() && !wlan->toDS() ) |
141 | { | 150 | { |
142 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", | 151 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", |
143 | (const char*) wlan->macAddress3().toString(true), | 152 | (const char*) wlan->macAddress3().toString(true), |
144 | (const char*) wlan->macAddress1().toString(true), | 153 | (const char*) wlan->macAddress1().toString(true), |
145 | (const char*) wlan->macAddress2().toString(true) ); | 154 | (const char*) wlan->macAddress2().toString(true) ); |
146 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), | 155 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), |
147 | wlan->macAddress1().toString(), | 156 | wlan->macAddress1().toString(), |
148 | wlan->macAddress2().toString() ); | 157 | wlan->macAddress2().toString() ); |
149 | } | 158 | } |
150 | else | 159 | else |
151 | if ( !wlan->fromDS() && wlan->toDS() ) | 160 | if ( !wlan->fromDS() && wlan->toDS() ) |
152 | { | 161 | { |
153 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", | 162 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", |
154 | (const char*) wlan->macAddress2().toString(true), | 163 | (const char*) wlan->macAddress2().toString(true), |
155 | (const char*) wlan->macAddress3().toString(true), | 164 | (const char*) wlan->macAddress3().toString(true), |
156 | (const char*) wlan->macAddress1().toString(true) ); | 165 | (const char*) wlan->macAddress1().toString(true) ); |
157 | netView()->traffic( "toDS", wlan->macAddress2().toString(), | 166 | netView()->traffic( "toDS", wlan->macAddress2().toString(), |
158 | wlan->macAddress3().toString(), | 167 | wlan->macAddress3().toString(), |
159 | wlan->macAddress1().toString() ); | 168 | wlan->macAddress1().toString() ); |
160 | } | 169 | } |
161 | else | 170 | else |
162 | if ( wlan->fromDS() && wlan->toDS() ) | 171 | if ( wlan->fromDS() && wlan->toDS() ) |
163 | { | 172 | { |
164 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", | 173 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", |
165 | (const char*) wlan->macAddress4().toString(true), | 174 | (const char*) wlan->macAddress4().toString(true), |
166 | (const char*) wlan->macAddress3().toString(true), | 175 | (const char*) wlan->macAddress3().toString(true), |
167 | (const char*) wlan->macAddress1().toString(true), | 176 | (const char*) wlan->macAddress1().toString(true), |
168 | (const char*) wlan->macAddress2().toString(true) ); | 177 | (const char*) wlan->macAddress2().toString(true) ); |
169 | netView()->traffic( "WSD", wlan->macAddress4().toString(), | 178 | netView()->traffic( "WSD", wlan->macAddress4().toString(), |
170 | wlan->macAddress3().toString(), | 179 | wlan->macAddress3().toString(), |
171 | wlan->macAddress1().toString(), | 180 | wlan->macAddress1().toString(), |
172 | wlan->macAddress2().toString() ); | 181 | wlan->macAddress2().toString() ); |
173 | } | 182 | } |
174 | else | 183 | else |
175 | { | 184 | { |
176 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", | 185 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", |
177 | (const char*) wlan->macAddress2().toString(true), | 186 | (const char*) wlan->macAddress2().toString(true), |
178 | (const char*) wlan->macAddress1().toString(true), | 187 | (const char*) wlan->macAddress1().toString(true), |
179 | (const char*) wlan->macAddress3().toString(true) ); | 188 | (const char*) wlan->macAddress3().toString(true) ); |
180 | netView()->traffic( "fromDS", wlan->macAddress2().toString(), | 189 | netView()->traffic( "fromDS", wlan->macAddress2().toString(), |
181 | wlan->macAddress1().toString(), | 190 | wlan->macAddress1().toString(), |
182 | wlan->macAddress3().toString() ); | 191 | wlan->macAddress3().toString() ); |
183 | } | 192 | } |
184 | return; | 193 | return; |
185 | } | 194 | } |
186 | } | 195 | } |
187 | 196 | ||
188 | void Wellenreiter::startStopClicked() | 197 | void Wellenreiter::startStopClicked() |
189 | { | 198 | { |
190 | if ( sniffing ) | 199 | if ( sniffing ) |
191 | { | 200 | { |
192 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 201 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
193 | 202 | ||
194 | iface->setChannelHopping(); // stop hopping channels | 203 | iface->setChannelHopping(); // stop hopping channels |
195 | pcap->close(); | 204 | pcap->close(); |
196 | sniffing = false; | 205 | sniffing = false; |
197 | #ifdef QWS | 206 | #ifdef QWS |
198 | oApp->setTitle(); | 207 | oApp->setTitle(); |
199 | #else | 208 | #else |
200 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | 209 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); |
201 | #endif | 210 | #endif |
202 | 211 | ||
203 | // get interface name from config window | 212 | // get interface name from config window |
204 | const QString& interface = configwindow->interfaceName->currentText(); | 213 | const QString& interface = configwindow->interfaceName->currentText(); |
205 | ONetwork* net = ONetwork::instance(); | 214 | ONetwork* net = ONetwork::instance(); |
206 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 215 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
207 | 216 | ||
208 | // switch off monitor mode | 217 | // switch off monitor mode |
209 | iface->setMonitorMode( false ); | 218 | iface->setMonitorMode( false ); |
210 | // switch off promisc flag | 219 | // switch off promisc flag |
211 | iface->setPromiscuousMode( false ); | 220 | iface->setPromiscuousMode( false ); |
212 | 221 | ||
213 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 222 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
214 | logwindow->log( "(i) Stopped Scanning." ); | 223 | logwindow->log( "(i) Stopped Scanning." ); |
215 | 224 | ||
216 | // message the user | 225 | // message the user |
217 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 226 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
218 | } | 227 | } |
219 | 228 | ||
220 | else | 229 | else |
221 | { | 230 | { |
222 | // get configuration from config window | 231 | // get configuration from config window |
223 | 232 | ||
224 | const QString& interface = configwindow->interfaceName->currentText(); | 233 | const QString& interface = configwindow->interfaceName->currentText(); |
225 | const int cardtype = configwindow->daemonDeviceType(); | 234 | const int cardtype = configwindow->daemonDeviceType(); |
226 | const int interval = configwindow->daemonHopInterval(); | 235 | const int interval = configwindow->daemonHopInterval(); |
227 | 236 | ||
228 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 237 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
229 | { | 238 | { |
230 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 239 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
231 | return; | 240 | return; |
232 | } | 241 | } |
233 | 242 | ||
234 | // configure device | 243 | // configure device |
235 | 244 | ||
236 | ONetwork* net = ONetwork::instance(); | 245 | ONetwork* net = ONetwork::instance(); |
237 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 246 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
238 | 247 | ||
239 | // set monitor mode | 248 | // set monitor mode |
240 | 249 | ||
241 | switch ( cardtype ) | 250 | switch ( cardtype ) |
242 | { | 251 | { |
243 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | 252 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
244 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | 253 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
245 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | 254 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
246 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | 255 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; |
247 | default: assert( 0 ); // shouldn't happen | 256 | default: assert( 0 ); // shouldn't happen |
248 | } | 257 | } |
249 | 258 | ||
250 | iface->setMonitorMode( true ); | 259 | iface->setMonitorMode( true ); |
251 | 260 | ||
252 | if ( !iface->monitorMode() ) | 261 | if ( !iface->monitorMode() ) |
253 | { | 262 | { |
254 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); | 263 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); |
255 | return; | 264 | return; |
256 | } | 265 | } |
257 | 266 | ||
258 | // open pcap and start sniffing | 267 | // open pcap and start sniffing |
259 | pcap->open( interface ); | 268 | pcap->open( interface ); |
260 | 269 | ||
261 | if ( !pcap->isOpen() ) | 270 | if ( !pcap->isOpen() ) |
262 | { | 271 | { |
263 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 272 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); |
264 | return; | 273 | return; |
265 | } | 274 | } |
266 | 275 | ||
267 | // set capturer to non-blocking mode | 276 | // set capturer to non-blocking mode |
268 | pcap->setBlocking( false ); | 277 | pcap->setBlocking( false ); |
269 | 278 | ||
270 | // start channel hopper | 279 | // start channel hopper |
271 | iface->setChannelHopping( 1000 ); //use interval from config window | 280 | iface->setChannelHopping( 1000 ); //use interval from config window |
272 | 281 | ||
273 | // connect | 282 | // connect |
274 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 283 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
275 | 284 | ||
276 | logwindow->log( "(i) Started Scanning." ); | 285 | logwindow->log( "(i) Started Scanning." ); |
277 | #ifdef QWS | 286 | #ifdef QWS |
278 | oApp->setTitle( "Scanning ..." ); | 287 | oApp->setTitle( "Scanning ..." ); |
279 | #else | 288 | #else |
280 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); | 289 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); |
281 | #endif | 290 | #endif |
282 | sniffing = true; | 291 | sniffing = true; |
283 | 292 | ||
284 | } | 293 | } |
285 | } | 294 | } |