-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 9d6ed6a..1cca507 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,569 +1,569 @@ | |||
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 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | #include <qcursor.h> | 21 | #include <qcursor.h> |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | 26 | ||
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <opie/odevice.h> | 29 | #include <opie/odevice.h> |
30 | using namespace Opie; | 30 | using namespace Opie; |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | 33 | ||
34 | #ifdef QWS | 34 | #ifdef QWS |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #else | 36 | #else |
37 | #include "resource.h" | 37 | #include "resource.h" |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | const int col_type = 0; | 40 | const int col_type = 0; |
41 | const int col_essid = 0; | 41 | const int col_essid = 0; |
42 | const int col_sig = 1; | 42 | const int col_sig = 1; |
43 | const int col_ap = 2; | 43 | const int col_ap = 2; |
44 | const int col_channel = 3; | 44 | const int col_channel = 3; |
45 | const int col_wep = 4; | 45 | const int col_wep = 4; |
46 | const int col_traffic = 5; | 46 | const int col_traffic = 5; |
47 | const int col_ip = 6; | 47 | const int col_ip = 6; |
48 | const int col_manuf = 7; | 48 | const int col_manuf = 7; |
49 | const int col_firstseen = 8; | 49 | const int col_firstseen = 8; |
50 | const int col_lastseen = 9; | 50 | const int col_lastseen = 9; |
51 | const int col_location = 10; | 51 | const int col_location = 10; |
52 | 52 | ||
53 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 53 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
54 | :OListView( parent, name ) | 54 | :OListView( parent, name ) |
55 | { | 55 | { |
56 | 56 | ||
57 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
58 | setFrameShadow( QListView::Sunken ); | 58 | setFrameShadow( QListView::Sunken ); |
59 | 59 | ||
60 | addColumn( tr( "Net/Station" ) ); | 60 | addColumn( tr( "Net/Station" ) ); |
61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
62 | addColumn( tr( "#" ) ); | 62 | addColumn( tr( "#" ) ); |
63 | setColumnAlignment( col_sig, AlignCenter ); | 63 | setColumnAlignment( col_sig, AlignCenter ); |
64 | addColumn( tr( "MAC" ) ); | 64 | addColumn( tr( "MAC" ) ); |
65 | setColumnAlignment( col_ap, AlignCenter ); | 65 | setColumnAlignment( col_ap, AlignCenter ); |
66 | addColumn( tr( "Chn" ) ); | 66 | addColumn( tr( "Chn" ) ); |
67 | setColumnAlignment( col_channel, AlignCenter ); | 67 | setColumnAlignment( col_channel, AlignCenter ); |
68 | addColumn( tr( "W" ) ); | 68 | addColumn( tr( "W" ) ); |
69 | setColumnAlignment( col_wep, AlignCenter ); | 69 | setColumnAlignment( col_wep, AlignCenter ); |
70 | addColumn( tr( "T" ) ); | 70 | addColumn( tr( "T" ) ); |
71 | setColumnAlignment( col_traffic, AlignCenter ); | 71 | setColumnAlignment( col_traffic, AlignCenter ); |
72 | addColumn( tr( "IP" ) ); | 72 | addColumn( tr( "IP" ) ); |
73 | setColumnAlignment( col_ip, AlignCenter ); | 73 | setColumnAlignment( col_ip, AlignCenter ); |
74 | addColumn( tr( "Manufacturer" ) ); | 74 | addColumn( tr( "Manufacturer" ) ); |
75 | setColumnAlignment( col_manuf, AlignCenter ); | 75 | setColumnAlignment( col_manuf, AlignCenter ); |
76 | addColumn( tr( "First Seen" ) ); | 76 | addColumn( tr( "First Seen" ) ); |
77 | setColumnAlignment( col_firstseen, AlignCenter ); | 77 | setColumnAlignment( col_firstseen, AlignCenter ); |
78 | addColumn( tr( "Last Seen" ) ); | 78 | addColumn( tr( "Last Seen" ) ); |
79 | setColumnAlignment( col_lastseen, AlignCenter ); | 79 | setColumnAlignment( col_lastseen, AlignCenter ); |
80 | addColumn( tr( "Location" ) ); | 80 | addColumn( tr( "Location" ) ); |
81 | setColumnAlignment( col_location, AlignCenter ); | 81 | setColumnAlignment( col_location, AlignCenter ); |
82 | setRootIsDecorated( true ); | 82 | setRootIsDecorated( true ); |
83 | setAllColumnsShowFocus( true ); | 83 | setAllColumnsShowFocus( true ); |
84 | 84 | ||
85 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 85 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
86 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 86 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
87 | 87 | ||
88 | #ifdef QWS | 88 | #ifdef QWS |
89 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 89 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | MScanListView::~MScanListView() | 95 | MScanListView::~MScanListView() |
96 | { | 96 | { |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OListViewItem* MScanListView::childFactory() | 100 | OListViewItem* MScanListView::childFactory() |
101 | { | 101 | { |
102 | return new MScanListItem( this ); | 102 | return new MScanListItem( this ); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
107 | { | 107 | { |
108 | qDebug( "serializing MScanListView" ); | 108 | qDebug( "serializing MScanListView" ); |
109 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
114 | { | 114 | { |
115 | qDebug( "serializing MScanListView" ); | 115 | qDebug( "serializing MScanListView" ); |
116 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void MScanListView::addNewItem( const QString& type, | 120 | void MScanListView::addNewItem( const QString& type, |
121 | const QString& essid, | 121 | const QString& essid, |
122 | const OMacAddress& mac, | 122 | const OMacAddress& mac, |
123 | bool wep, | 123 | bool wep, |
124 | int channel, | 124 | int channel, |
125 | int signal, | 125 | int signal, |
126 | const GpsLocation& loc ) | 126 | const GpsLocation& loc ) |
127 | { | 127 | { |
128 | QString macaddr = mac.toString(true); | 128 | QString macaddr = mac.toString(true); |
129 | 129 | ||
130 | #ifdef DEBUG | 130 | #ifdef DEBUG |
131 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 131 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
132 | (const char*) essid, (const char*) macaddr, channel ); | 132 | (const char*) essid, (const char*) macaddr, channel ); |
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | // search, if we already have seen this net | 135 | // search, if we already have seen this net |
136 | 136 | ||
137 | QString s; | 137 | QString s; |
138 | MScanListItem* network; | 138 | MScanListItem* network; |
139 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 139 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
140 | 140 | ||
141 | while ( item && ( item->text( col_essid ) != essid ) ) | 141 | while ( item && ( item->text( col_essid ) != essid ) ) |
142 | { | 142 | { |
143 | #ifdef DEBUG | 143 | #ifdef DEBUG |
144 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 144 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
145 | #endif | 145 | #endif |
146 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 146 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
147 | } | 147 | } |
148 | if ( item ) | 148 | if ( item ) |
149 | { | 149 | { |
150 | // we have already seen this net, check all childs if MAC exists | 150 | // we have already seen this net, check all childs if MAC exists |
151 | 151 | ||
152 | network = item; | 152 | network = item; |
153 | 153 | ||
154 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 154 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
155 | assert( item ); // this shouldn't fail | 155 | assert( item ); // this shouldn't fail |
156 | 156 | ||
157 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 157 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
158 | { | 158 | { |
159 | #ifdef DEBUG | 159 | #ifdef DEBUG |
160 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 160 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
161 | #endif | 161 | #endif |
162 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 162 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
163 | } | 163 | } |
164 | 164 | ||
165 | if ( item ) | 165 | if ( item ) |
166 | { | 166 | { |
167 | // we have already seen this item, it's a dupe | 167 | // we have already seen this item, it's a dupe |
168 | #ifdef DEBUG | 168 | #ifdef DEBUG |
169 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 169 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
170 | #endif | 170 | #endif |
171 | item->receivedBeacon(); | 171 | item->receivedBeacon(); |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | else | 175 | else |
176 | { | 176 | { |
177 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 177 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
178 | MLogWindow::logwindow()->log( s ); | 178 | MLogWindow::logwindow()->log( s ); |
179 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 179 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | // insert new station as child from network | 183 | // insert new station as child from network |
184 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 184 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
185 | 185 | ||
186 | #ifdef DEBUG | 186 | #ifdef DEBUG |
187 | qDebug( "inserting new station %s", (const char*) macaddr ); | 187 | qDebug( "inserting new station %s", (const char*) macaddr ); |
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
191 | station->setManufacturer( mac.manufacturer() ); | 191 | station->setManufacturer( mac.manufacturer() ); |
192 | station->setLocation( loc.latitude, loc.longitude ); | 192 | station->setLocation( loc.latitude, loc.longitude ); |
193 | 193 | ||
194 | if ( type == "managed" ) | 194 | if ( type == "managed" ) |
195 | { | 195 | { |
196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
197 | } | 197 | } |
198 | else | 198 | else |
199 | { | 199 | { |
200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
201 | } | 201 | } |
202 | MLogWindow::logwindow()->log( s ); | 202 | MLogWindow::logwindow()->log( s ); |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
208 | { | 208 | { |
209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
210 | 210 | ||
211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
212 | { | 212 | { |
213 | #ifdef DEBUG | 213 | #ifdef DEBUG |
214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
215 | #endif | 215 | #endif |
216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
217 | } | 217 | } |
218 | 218 | ||
219 | if ( subitem ) | 219 | if ( subitem ) |
220 | { | 220 | { |
221 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
222 | #ifdef DEBUG | 222 | #ifdef DEBUG |
223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
224 | #endif | 224 | #endif |
225 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | // Hey, it seems to be a new item :-D | 229 | // Hey, it seems to be a new item :-D |
230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
231 | station->setManufacturer( addr.manufacturer() ); | 231 | station->setManufacturer( addr.manufacturer() ); |
232 | 232 | ||
233 | QString s; | 233 | QString s; |
234 | if ( type == "station" ) | 234 | if ( type == "station" ) |
235 | { | 235 | { |
236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
241 | } | 241 | } |
242 | MLogWindow::logwindow()->log( s ); | 242 | MLogWindow::logwindow()->log( s ); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
247 | { | 247 | { |
248 | QString s; | 248 | QString s; |
249 | MScanListItem* network; | 249 | MScanListItem* network; |
250 | 250 | ||
251 | QListViewItemIterator it( this ); | 251 | QListViewItemIterator it( this ); |
252 | while ( it.current() && | 252 | while ( it.current() && |
253 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 253 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 254 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
255 | 255 | ||
256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 256 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
257 | 257 | ||
258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 258 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
259 | { | 259 | { |
260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 260 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
262 | } | 262 | } |
263 | else | 263 | else |
264 | { | 264 | { |
265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 265 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 266 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 271 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
272 | { | 272 | { |
273 | QString s; | 273 | QString s; |
274 | MScanListItem* network; | 274 | MScanListItem* network; |
275 | 275 | ||
276 | QListViewItemIterator it( this ); | 276 | QListViewItemIterator it( this ); |
277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 277 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
278 | 278 | ||
279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 279 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
280 | 280 | ||
281 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 281 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
282 | { | 282 | { |
283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
289 | 289 | ||
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
295 | { | 295 | { |
296 | QString s; | 296 | QString s; |
297 | MScanListItem* network; | 297 | MScanListItem* network; |
298 | 298 | ||
299 | QListViewItemIterator it( this ); | 299 | QListViewItemIterator it( this ); |
300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
301 | 301 | ||
302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
303 | 303 | ||
304 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 304 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
305 | { | 305 | { |
306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
307 | } | 307 | } |
308 | else | 308 | else |
309 | { | 309 | { |
310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
317 | { | 317 | { |
318 | qWarning( "D'oh! Not yet implemented..." ); | 318 | qWarning( "D'oh! Not yet implemented..." ); |
319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
324 | { | 324 | { |
325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
326 | 326 | ||
327 | QListViewItemIterator it( this ); | 327 | QListViewItemIterator it( this ); |
328 | for ( ; it.current(); ++it ) | 328 | for ( ; it.current(); ++it ) |
329 | { | 329 | { |
330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
331 | { | 331 | { |
332 | it.current()->setText( col_ip, ip ); | 332 | it.current()->setText( col_ip, ip ); |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
338 | (const char*) macaddr.toString(), (const char*) ip ) ); | 338 | (const char*) macaddr.toString(), (const char*) ip ) ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 342 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
343 | { | 343 | { |
344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 344 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
345 | 345 | ||
346 | //TODO: Refactor that out, we need it all over the place. | 346 | //TODO: Refactor that out, we need it all over the place. |
347 | // Best to do it in a more comfortable abstraction in OListView | 347 | // Best to do it in a more comfortable abstraction in OListView |
348 | // (Hmm, didn't I already start something in this direction?) | 348 | // (Hmm, didn't I already start something in this direction?) |
349 | 349 | ||
350 | QListViewItemIterator it( this ); | 350 | QListViewItemIterator it( this ); |
351 | for ( ; it.current(); ++it ) | 351 | for ( ; it.current(); ++it ) |
352 | { | 352 | { |
353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 353 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
354 | { | 354 | { |
355 | 355 | ||
356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 356 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
357 | 357 | ||
358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 358 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
359 | { | 359 | { |
360 | #ifdef DEBUG | 360 | #ifdef DEBUG |
361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 361 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
362 | #endif | 362 | #endif |
363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 363 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
364 | } | 364 | } |
365 | 365 | ||
366 | if ( subitem ) | 366 | if ( subitem ) |
367 | { | 367 | { |
368 | // we have already seen this item, it's a dupe | 368 | // we have already seen this item, it's a dupe |
369 | #ifdef DEBUG | 369 | #ifdef DEBUG |
370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 370 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
371 | #endif | 371 | #endif |
372 | subitem->receivedBeacon(); //FIXME: sent data bit | 372 | subitem->receivedBeacon(); //FIXME: sent data bit |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | 375 | ||
376 | // never seen that - add new item | 376 | // never seen that - add new item |
377 | 377 | ||
378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 ); | 378 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
379 | item->setText( col_essid, name ); | 379 | item->setText( col_essid, name ); |
380 | 380 | ||
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 384 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 385 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
386 | (const char*) macaddr.toString(), (const char*) ip ) ); | 386 | (const char*) macaddr.toString(), (const char*) ip ) ); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 390 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
391 | { | 391 | { |
392 | if ( !item ) return; | 392 | if ( !item ) return; |
393 | 393 | ||
394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 394 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
395 | 395 | ||
396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 396 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
397 | (const char*) itm->text(0), (const char*) itm->type, col ); | 397 | (const char*) itm->text(0), (const char*) itm->type, col ); |
398 | 398 | ||
399 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 399 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
400 | { | 400 | { |
401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 401 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
402 | 402 | ||
403 | QPopupMenu m( this ); | 403 | QPopupMenu m( this ); |
404 | m.insertItem( entry, 37773, 0 ); | 404 | m.insertItem( entry, 37773, 0 ); |
405 | int result = m.exec( QCursor::pos() ); | 405 | int result = m.exec( QCursor::pos() ); |
406 | if ( result == 37773 ) | 406 | if ( result == 37773 ) |
407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 407 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | 410 | ||
411 | //============================================================ | 411 | //============================================================ |
412 | // MScanListItem | 412 | // MScanListItem |
413 | //============================================================ | 413 | //============================================================ |
414 | 414 | ||
415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 415 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
416 | bool wep, int channel, int signal ) | 416 | bool wep, int channel, int signal ) |
417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 417 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 418 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
419 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 419 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
420 | { | 420 | { |
421 | #ifdef DEBUG | 421 | #ifdef DEBUG |
422 | qDebug( "creating scanlist item" ); | 422 | qDebug( "creating scanlist item" ); |
423 | #endif | 423 | #endif |
424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 424 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 425 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
426 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 426 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
427 | } | 427 | } |
428 | 428 | ||
429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 429 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
430 | bool wep, int channel, int signal ) | 430 | bool wep, int channel, int signal ) |
431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
432 | { | 432 | { |
433 | #ifdef DEBUG | 433 | #ifdef DEBUG |
434 | qDebug( "creating scanlist item" ); | 434 | qDebug( "creating scanlist item" ); |
435 | #endif | 435 | #endif |
436 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 436 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
437 | } | 437 | } |
438 | 438 | ||
439 | const QString& MScanListItem::essid() const | 439 | const QString& MScanListItem::essid() const |
440 | { | 440 | { |
441 | if ( type == "network" ) | 441 | if ( type == "network" ) |
442 | return _essid; | 442 | return _essid; |
443 | else | 443 | else |
444 | return ( (MScanListItem*) parent() )->essid(); | 444 | return ( (MScanListItem*) parent() )->essid(); |
445 | } | 445 | } |
446 | 446 | ||
447 | OListViewItem* MScanListItem::childFactory() | 447 | OListViewItem* MScanListItem::childFactory() |
448 | { | 448 | { |
449 | return new MScanListItem( this ); | 449 | return new MScanListItem( this ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void MScanListItem::serializeTo( QDataStream& s ) const | 452 | void MScanListItem::serializeTo( QDataStream& s ) const |
453 | { | 453 | { |
454 | #ifdef DEBUG | 454 | #ifdef DEBUG |
455 | qDebug( "serializing MScanListItem" ); | 455 | qDebug( "serializing MScanListItem" ); |
456 | #endif | 456 | #endif |
457 | OListViewItem::serializeTo( s ); | 457 | OListViewItem::serializeTo( s ); |
458 | 458 | ||
459 | s << _type; | 459 | s << _type; |
460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 460 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void MScanListItem::serializeFrom( QDataStream& s ) | 463 | void MScanListItem::serializeFrom( QDataStream& s ) |
464 | { | 464 | { |
465 | #ifdef DEBUG | 465 | #ifdef DEBUG |
466 | qDebug( "serializing MScanListItem" ); | 466 | qDebug( "serializing MScanListItem" ); |
467 | #endif | 467 | #endif |
468 | OListViewItem::serializeFrom( s ); | 468 | OListViewItem::serializeFrom( s ); |
469 | 469 | ||
470 | char wep; | 470 | char wep; |
471 | s >> _type; | 471 | s >> _type; |
472 | s >> (Q_UINT8) wep; | 472 | s >> (Q_UINT8) wep; |
473 | _wep = (wep == 'y'); | 473 | _wep = (wep == 'y'); |
474 | 474 | ||
475 | QString name; | 475 | QString name; |
476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 476 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
477 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 477 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
478 | if ( _wep ) | 478 | if ( _wep ) |
479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 479 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
480 | listView()->triggerUpdate(); | 480 | listView()->triggerUpdate(); |
481 | } | 481 | } |
482 | 482 | ||
483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 483 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
484 | { | 484 | { |
485 | #ifdef DEBUG | 485 | #ifdef DEBUG |
486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 486 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
487 | (const char*) type, | 487 | (const char*) type, |
488 | (const char*) essid, | 488 | (const char*) essid, |
489 | (const char*) macaddr, | 489 | (const char*) macaddr, |
490 | channel ); | 490 | channel ); |
491 | #endif | 491 | #endif |
492 | 492 | ||
493 | // set icon for managed or adhoc mode | 493 | // set icon for managed or adhoc mode |
494 | QString name; | 494 | QString name; |
495 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 495 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
496 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 496 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
497 | 497 | ||
498 | // set icon for wep (wireless encryption protocol) | 498 | // set icon for wep (wireless encryption protocol) |
499 | if ( wep ) | 499 | if ( wep ) |
500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 500 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
501 | 501 | ||
502 | // set channel and signal text | 502 | // set channel and signal text |
503 | 503 | ||
504 | if ( signal != -1 ) | 504 | if ( signal != -1 ) |
505 | setText( col_sig, QString::number( signal ) ); | 505 | setText( col_sig, QString::number( signal ) ); |
506 | if ( channel != -1 ) | 506 | if ( channel != -1 ) |
507 | setText( col_channel, QString::number( channel ) ); | 507 | setText( col_channel, QString::number( channel ) ); |
508 | 508 | ||
509 | setText( col_firstseen, QTime::currentTime().toString() ); | 509 | setText( col_firstseen, QTime::currentTime().toString() ); |
510 | //setText( col_lastseen, QTime::currentTime().toString() ); | 510 | //setText( col_lastseen, QTime::currentTime().toString() ); |
511 | 511 | ||
512 | listView()->triggerUpdate(); | 512 | listView()->triggerUpdate(); |
513 | 513 | ||
514 | this->type = type; | 514 | this->type = type; |
515 | _type = type; | 515 | _type = type; |
516 | _essid = essid; | 516 | _essid = essid; |
517 | _macaddr = macaddr; | 517 | _macaddr = macaddr; |
518 | _channel = channel; | 518 | _channel = channel; |
519 | _beacons = 1; | 519 | _beacons = 1; |
520 | _signal = 0; | 520 | _signal = 0; |
521 | 521 | ||
522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 522 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
523 | { | 523 | { |
524 | listView()->ensureItemVisible( this ); | 524 | listView()->ensureItemVisible( this ); |
525 | } | 525 | } |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 530 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
531 | { | 531 | { |
532 | setText( col_manuf, manufacturer ); | 532 | setText( col_manuf, manufacturer ); |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | 536 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) |
537 | { | 537 | { |
538 | if ( latitude == 0.0 || longitude == 0.0 ) | 538 | if ( latitude == 0.0 || longitude == 0.0 ) |
539 | setText( col_location, "N/A" ); | 539 | setText( col_location, "N/A" ); |
540 | else | 540 | else |
541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | 541 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | void MScanListItem::playSound( const QString& sound ) const | 545 | void MScanListItem::playSound( const QString& sound ) const |
546 | { | 546 | { |
547 | #ifdef QWS | 547 | #ifdef QWS |
548 | if ( sound == "Ignore" ) return; | 548 | if ( sound == "Ignore" ) return; |
549 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 549 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
550 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 550 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
551 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 551 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
552 | #endif | 552 | #endif |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | void MScanListItem::receivedBeacon() | 556 | void MScanListItem::receivedBeacon() |
557 | { | 557 | { |
558 | _beacons++; | 558 | _beacons++; |
559 | #ifdef DEBUG | 559 | #ifdef DEBUG |
560 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 560 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
561 | #endif | 561 | #endif |
562 | setText( col_sig, QString::number( _beacons ) ); | 562 | setText( col_sig, QString::number( _beacons ) ); |
563 | setText( col_lastseen, QTime::currentTime().toString() ); | 563 | setText( col_lastseen, QTime::currentTime().toString() ); |
564 | 564 | ||
565 | MScanListItem* p = (MScanListItem*) parent(); | 565 | MScanListItem* p = (MScanListItem*) parent(); |
566 | if ( p ) p->receivedBeacon(); | 566 | if ( p ) p->receivedBeacon(); |
567 | 567 | ||
568 | } | 568 | } |
569 | 569 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 7394742..9460f56 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,632 +1,635 @@ | |||
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 | // Local | 16 | // Local |
17 | 17 | ||
18 | #include "gps.h" | 18 | #include "gps.h" |
19 | #include "wellenreiter.h" | 19 | #include "wellenreiter.h" |
20 | #include "scanlist.h" | 20 | #include "scanlist.h" |
21 | #include "logwindow.h" | 21 | #include "logwindow.h" |
22 | #include "hexwindow.h" | 22 | #include "hexwindow.h" |
23 | #include "configwindow.h" | 23 | #include "configwindow.h" |
24 | #include "statwindow.h" | 24 | #include "statwindow.h" |
25 | #include "graphwindow.h" | 25 | #include "graphwindow.h" |
26 | #include "protolistview.h" | 26 | #include "protolistview.h" |
27 | 27 | ||
28 | // Opie | 28 | // Opie |
29 | 29 | ||
30 | #ifdef QWS | 30 | #ifdef QWS |
31 | #include <opie/odevice.h> | 31 | #include <opie/odevice.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | using namespace Opie; | 33 | using namespace Opie; |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifdef QWS | 36 | #ifdef QWS |
37 | #include <opie2/oapplication.h> | 37 | #include <opie2/oapplication.h> |
38 | #else | 38 | #else |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #endif | 40 | #endif |
41 | #include <opie2/onetwork.h> | 41 | #include <opie2/onetwork.h> |
42 | #include <opie2/opcap.h> | 42 | #include <opie2/opcap.h> |
43 | 43 | ||
44 | // Qt | 44 | // Qt |
45 | 45 | ||
46 | #include <qcheckbox.h> | 46 | #include <qcheckbox.h> |
47 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
48 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
49 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qobjectlist.h> | 52 | #include <qobjectlist.h> |
53 | #include <qregexp.h> | 53 | #include <qregexp.h> |
54 | #include <qspinbox.h> | 54 | #include <qspinbox.h> |
55 | #include <qtoolbutton.h> | 55 | #include <qtoolbutton.h> |
56 | #include <qmainwindow.h> | 56 | #include <qmainwindow.h> |
57 | 57 | ||
58 | // Standard | 58 | // Standard |
59 | 59 | ||
60 | #include <assert.h> | 60 | #include <assert.h> |
61 | #include <errno.h> | 61 | #include <errno.h> |
62 | #include <unistd.h> | 62 | #include <unistd.h> |
63 | #include <string.h> | 63 | #include <string.h> |
64 | #include <sys/types.h> | 64 | #include <sys/types.h> |
65 | #include <stdlib.h> | 65 | #include <stdlib.h> |
66 | 66 | ||
67 | Wellenreiter::Wellenreiter( QWidget* parent ) | 67 | Wellenreiter::Wellenreiter( QWidget* parent ) |
68 | : WellenreiterBase( parent, 0, 0 ), | 68 | : WellenreiterBase( parent, 0, 0 ), |
69 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 69 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
70 | { | 70 | { |
71 | 71 | ||
72 | logwindow->log( "(i) Wellenreiter has been started." ); | 72 | logwindow->log( "(i) Wellenreiter has been started." ); |
73 | 73 | ||
74 | // | 74 | // |
75 | // detect operating system | 75 | // detect operating system |
76 | // | 76 | // |
77 | 77 | ||
78 | #ifdef QWS | 78 | #ifdef QWS |
79 | QString sys; | 79 | QString sys; |
80 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 80 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
81 | _system = ODevice::inst()->system(); | 81 | _system = ODevice::inst()->system(); |
82 | logwindow->log( sys ); | 82 | logwindow->log( sys ); |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | netview->setColumnWidthMode( 1, QListView::Manual ); | 85 | netview->setColumnWidthMode( 1, QListView::Manual ); |
86 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 86 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
87 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 87 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
88 | pcap = new OPacketCapturer(); | 88 | pcap = new OPacketCapturer(); |
89 | 89 | ||
90 | gps = new GPS( this ); | 90 | gps = new GPS( this ); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | Wellenreiter::~Wellenreiter() | 94 | Wellenreiter::~Wellenreiter() |
95 | { | 95 | { |
96 | delete pcap; | 96 | delete pcap; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 100 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
101 | { | 101 | { |
102 | configwindow = cw; | 102 | configwindow = cw; |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void Wellenreiter::channelHopped(int c) | 106 | void Wellenreiter::channelHopped(int c) |
107 | { | 107 | { |
108 | QString title = "Wellenreiter II -scan- ["; | 108 | QString title = "Wellenreiter II -scan- ["; |
109 | QString left; | 109 | QString left; |
110 | if ( c > 1 ) left.fill( '.', c-1 ); | 110 | if ( c > 1 ) left.fill( '.', c-1 ); |
111 | title.append( left ); | 111 | title.append( left ); |
112 | title.append( '|' ); | 112 | title.append( '|' ); |
113 | if ( c < iface->channels() ) | 113 | if ( c < iface->channels() ) |
114 | { | 114 | { |
115 | QString right; | 115 | QString right; |
116 | right.fill( '.', iface->channels()-c ); | 116 | right.fill( '.', iface->channels()-c ); |
117 | title.append( right ); | 117 | title.append( right ); |
118 | } | 118 | } |
119 | title.append( "]" ); | 119 | title.append( "]" ); |
120 | //title.append( QString().sprintf( " %02d", c ) ); | 120 | //title.append( QString().sprintf( " %02d", c ) ); |
121 | assert( parent() ); | 121 | assert( parent() ); |
122 | ( (QMainWindow*) parent() )->setCaption( title ); | 122 | ( (QMainWindow*) parent() )->setCaption( title ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void Wellenreiter::handleNotification( OPacket* p ) | 126 | void Wellenreiter::handleNotification( OPacket* p ) |
127 | { | 127 | { |
128 | QObjectList* l = p->queryList(); | 128 | QObjectList* l = p->queryList(); |
129 | QObjectListIt it( *l ); | 129 | QObjectListIt it( *l ); |
130 | QObject* o; | 130 | QObject* o; |
131 | 131 | ||
132 | while ( (o = it.current()) != 0 ) | 132 | while ( (o = it.current()) != 0 ) |
133 | { | 133 | { |
134 | QString name = it.current()->name(); | 134 | QString name = it.current()->name(); |
135 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 135 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
136 | { | 136 | { |
137 | QString action = configwindow->parsePackets->protocolAction( name ); | 137 | QString action = configwindow->parsePackets->protocolAction( name ); |
138 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 138 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
139 | doAction( action, name, p ); | 139 | doAction( action, name, p ); |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | { |
143 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 143 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
144 | } | 144 | } |
145 | ++it; | 145 | ++it; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 150 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
151 | { | 151 | { |
152 | QString type; | 152 | QString type; |
153 | if ( beacon->canIBSS() ) | 153 | if ( beacon->canIBSS() ) |
154 | { | 154 | { |
155 | type = "adhoc"; | 155 | type = "adhoc"; |
156 | } | 156 | } |
157 | else if ( beacon->canESS() ) | 157 | else if ( beacon->canESS() ) |
158 | { | 158 | { |
159 | type = "managed"; | 159 | type = "managed"; |
160 | } | 160 | } |
161 | else | 161 | else |
162 | { | 162 | { |
163 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 163 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
168 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 168 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
170 | int channel = ds ? ds->channel() : -1; | 170 | int channel = ds ? ds->channel() : -1; |
171 | 171 | ||
172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
173 | 173 | ||
174 | GpsLocation loc( 0, 0 ); | 174 | GpsLocation loc( 0, 0 ); |
175 | if ( configwindow->enableGPS->isChecked() ) | 175 | if ( configwindow->enableGPS->isChecked() ) |
176 | { | 176 | { |
177 | // TODO: add check if GPS is working!? | 177 | // TODO: add check if GPS is working!? |
178 | qDebug( "Wellenreiter::gathering GPS data..." ); | 178 | qDebug( "Wellenreiter::gathering GPS data..." ); |
179 | loc = gps->position(); | 179 | loc = gps->position(); |
180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); | 180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude ); |
181 | } | 181 | } |
182 | 182 | ||
183 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 183 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
184 | 184 | ||
185 | // update graph window | 185 | // update graph window |
186 | if ( ds ) | 186 | if ( ds ) |
187 | { | 187 | { |
188 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 188 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
189 | if ( prism ) | 189 | if ( prism ) |
190 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 190 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
191 | else | 191 | else |
192 | graphwindow->traffic( ds->channel(), 95 ); | 192 | graphwindow->traffic( ds->channel(), 95 ); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 197 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
198 | { | 198 | { |
199 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 199 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
200 | if ( wlan->fromDS() && !wlan->toDS() ) | 200 | if ( wlan->fromDS() && !wlan->toDS() ) |
201 | { | 201 | { |
202 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 202 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
203 | from = wlan->macAddress3(); | 203 | from = wlan->macAddress3(); |
204 | to = wlan->macAddress2(); | 204 | to = wlan->macAddress2(); |
205 | } | 205 | } |
206 | else if ( !wlan->fromDS() && wlan->toDS() ) | 206 | else if ( !wlan->fromDS() && wlan->toDS() ) |
207 | { | 207 | { |
208 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 208 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
209 | from = wlan->macAddress2(); | 209 | from = wlan->macAddress2(); |
210 | to = wlan->macAddress3(); | 210 | to = wlan->macAddress3(); |
211 | } | 211 | } |
212 | else if ( wlan->fromDS() && wlan->toDS() ) | 212 | else if ( wlan->fromDS() && wlan->toDS() ) |
213 | { | 213 | { |
214 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 214 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
215 | from = wlan->macAddress4(); | 215 | from = wlan->macAddress4(); |
216 | to = wlan->macAddress3(); | 216 | to = wlan->macAddress3(); |
217 | } | 217 | } |
218 | else | 218 | else |
219 | { | 219 | { |
220 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 220 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
221 | from = wlan->macAddress2(); | 221 | from = wlan->macAddress2(); |
222 | to = wlan->macAddress1(); | 222 | to = wlan->macAddress1(); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) | 227 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) |
228 | { | 228 | { |
229 | from = data->sourceAddress(); | 229 | from = data->sourceAddress(); |
230 | to = data->destinationAddress(); | 230 | to = data->destinationAddress(); |
231 | 231 | ||
232 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); | 232 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 236 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
237 | { | 237 | { |
238 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 238 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
239 | if ( arp ) | 239 | if ( arp ) |
240 | { | 240 | { |
241 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 241 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
242 | if ( arp->type() == "REQUEST" ) | 242 | if ( arp->type() == "REQUEST" ) |
243 | { | 243 | { |
244 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 244 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
245 | } | 245 | } |
246 | else if ( arp->type() == "REPLY" ) | 246 | else if ( arp->type() == "REPLY" ) |
247 | { | 247 | { |
248 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 248 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
249 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 249 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 253 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
254 | if ( dhcp ) | 254 | if ( dhcp ) |
255 | { | 255 | { |
256 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 256 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); |
257 | if ( dhcp->type() == "OFFER" ) | 257 | if ( dhcp->type() == "OFFER" ) |
258 | { | 258 | { |
259 | qDebug( "ADDSERVICE: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 259 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); |
260 | //netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); | ||
261 | |||
262 | netView()->identify( source, dhcp->serverAddress().toString() ); | 260 | netView()->identify( source, dhcp->serverAddress().toString() ); |
263 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 261 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
264 | } | 262 | } |
263 | else if ( dhcp->type() == "ACK" ) | ||
264 | { | ||
265 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | ||
266 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | ||
267 | } | ||
265 | } | 268 | } |
266 | } | 269 | } |
267 | 270 | ||
268 | 271 | ||
269 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 272 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
270 | { | 273 | { |
271 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 274 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
272 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 275 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
273 | return 0; | 276 | return 0; |
274 | 277 | ||
275 | return p->child( protocol ); | 278 | return p->child( protocol ); |
276 | } | 279 | } |
277 | 280 | ||
278 | 281 | ||
279 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 282 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
280 | { | 283 | { |
281 | // go through all child packets and see if one is inside the child hierarchy for p | 284 | // go through all child packets and see if one is inside the child hierarchy for p |
282 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 285 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
283 | if ( !configwindow->writeCaptureFile->isChecked() ) | 286 | if ( !configwindow->writeCaptureFile->isChecked() ) |
284 | return false; | 287 | return false; |
285 | 288 | ||
286 | QObjectList* l = p->queryList(); | 289 | QObjectList* l = p->queryList(); |
287 | QObjectListIt it( *l ); | 290 | QObjectListIt it( *l ); |
288 | QObject* o; | 291 | QObject* o; |
289 | 292 | ||
290 | while ( (o = it.current()) != 0 ) | 293 | while ( (o = it.current()) != 0 ) |
291 | { | 294 | { |
292 | QString name = it.current()->name(); | 295 | QString name = it.current()->name(); |
293 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 296 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
294 | { | 297 | { |
295 | QString action = configwindow->capturePackets->protocolAction( name ); | 298 | QString action = configwindow->capturePackets->protocolAction( name ); |
296 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 299 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
297 | if ( action == "Discard" ) | 300 | if ( action == "Discard" ) |
298 | { | 301 | { |
299 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 302 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
300 | return false; | 303 | return false; |
301 | } | 304 | } |
302 | } | 305 | } |
303 | else | 306 | else |
304 | { | 307 | { |
305 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 308 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
306 | } | 309 | } |
307 | ++it; | 310 | ++it; |
308 | } | 311 | } |
309 | return true; | 312 | return true; |
310 | } | 313 | } |
311 | 314 | ||
312 | 315 | ||
313 | void Wellenreiter::receivePacket( OPacket* p ) | 316 | void Wellenreiter::receivePacket( OPacket* p ) |
314 | { | 317 | { |
315 | hexWindow()->log( p->dump( 8 ) ); | 318 | hexWindow()->log( p->dump( 8 ) ); |
316 | 319 | ||
317 | if ( checkDumpPacket( p ) ) | 320 | if ( checkDumpPacket( p ) ) |
318 | { | 321 | { |
319 | pcap->dump( p ); | 322 | pcap->dump( p ); |
320 | } | 323 | } |
321 | 324 | ||
322 | // check if we received a beacon frame | 325 | // check if we received a beacon frame |
323 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 326 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
324 | if ( beacon && beacon->managementType() == "Beacon" ) | 327 | if ( beacon && beacon->managementType() == "Beacon" ) |
325 | { | 328 | { |
326 | handleBeacon( p, beacon ); | 329 | handleBeacon( p, beacon ); |
327 | return; | 330 | return; |
328 | } | 331 | } |
329 | 332 | ||
330 | OMacAddress source; | 333 | OMacAddress source; |
331 | OMacAddress dest; | 334 | OMacAddress dest; |
332 | 335 | ||
333 | //TODO: WEP check here | 336 | //TODO: WEP check here |
334 | 337 | ||
335 | // check for a wireless data frame | 338 | // check for a wireless data frame |
336 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 339 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
337 | if ( wlan ) | 340 | if ( wlan ) |
338 | { | 341 | { |
339 | handleWlanData( p, wlan, source, dest ); | 342 | handleWlanData( p, wlan, source, dest ); |
340 | } | 343 | } |
341 | 344 | ||
342 | // check for a wired data frame | 345 | // check for a wired data frame |
343 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); | 346 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); |
344 | if ( eth ) | 347 | if ( eth ) |
345 | { | 348 | { |
346 | handleEthernetData( p, eth, source, dest ); | 349 | handleEthernetData( p, eth, source, dest ); |
347 | } | 350 | } |
348 | 351 | ||
349 | // check for a ip frame | 352 | // check for a ip frame |
350 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); | 353 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); |
351 | if ( ip ) | 354 | if ( ip ) |
352 | { | 355 | { |
353 | handleIPData( p, ip, source, dest ); | 356 | handleIPData( p, ip, source, dest ); |
354 | } | 357 | } |
355 | 358 | ||
356 | //handleNotification( p ); | 359 | //handleNotification( p ); |
357 | 360 | ||
358 | } | 361 | } |
359 | 362 | ||
360 | 363 | ||
361 | void Wellenreiter::stopClicked() | 364 | void Wellenreiter::stopClicked() |
362 | { | 365 | { |
363 | if ( iface ) | 366 | if ( iface ) |
364 | { | 367 | { |
365 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 368 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
366 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 369 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
367 | iface->setChannelHopping(); // stop hopping channels | 370 | iface->setChannelHopping(); // stop hopping channels |
368 | } | 371 | } |
369 | else | 372 | else |
370 | killTimers(); | 373 | killTimers(); |
371 | 374 | ||
372 | pcap->close(); | 375 | pcap->close(); |
373 | sniffing = false; | 376 | sniffing = false; |
374 | 377 | ||
375 | if ( iface ) | 378 | if ( iface ) |
376 | { | 379 | { |
377 | // switch off monitor mode | 380 | // switch off monitor mode |
378 | iface->setMonitorMode( false ); | 381 | iface->setMonitorMode( false ); |
379 | // switch off promisc flag | 382 | // switch off promisc flag |
380 | iface->setPromiscuousMode( false ); | 383 | iface->setPromiscuousMode( false ); |
381 | 384 | ||
382 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 385 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
383 | } | 386 | } |
384 | 387 | ||
385 | logwindow->log( "(i) Stopped Scanning." ); | 388 | logwindow->log( "(i) Stopped Scanning." ); |
386 | assert( parent() ); | 389 | assert( parent() ); |
387 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 390 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
388 | 391 | ||
389 | // message the user | 392 | // message the user |
390 | QMessageBox::information( this, "Wellenreiter II", | 393 | QMessageBox::information( this, "Wellenreiter II", |
391 | tr( "Your wireless card\nshould now be usable again." ) ); | 394 | tr( "Your wireless card\nshould now be usable again." ) ); |
392 | 395 | ||
393 | sniffing = false; | 396 | sniffing = false; |
394 | emit( stoppedSniffing() ); | 397 | emit( stoppedSniffing() ); |
395 | 398 | ||
396 | #ifdef QWS | 399 | #ifdef QWS |
397 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 400 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
398 | { | 401 | { |
399 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 402 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
400 | } | 403 | } |
401 | #else | 404 | #else |
402 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 405 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
403 | #endif | 406 | #endif |
404 | 407 | ||
405 | // print out statistics | 408 | // print out statistics |
406 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 409 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
407 | statwindow->updateCounter( it.key(), it.data() ); | 410 | statwindow->updateCounter( it.key(), it.data() ); |
408 | } | 411 | } |
409 | 412 | ||
410 | 413 | ||
411 | void Wellenreiter::startClicked() | 414 | void Wellenreiter::startClicked() |
412 | { | 415 | { |
413 | // get configuration from config window | 416 | // get configuration from config window |
414 | 417 | ||
415 | const QString& interface = configwindow->interfaceName->currentText(); | 418 | const QString& interface = configwindow->interfaceName->currentText(); |
416 | const int cardtype = configwindow->driverType(); | 419 | const int cardtype = configwindow->driverType(); |
417 | const int interval = configwindow->hoppingInterval(); | 420 | const int interval = configwindow->hoppingInterval(); |
418 | 421 | ||
419 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 422 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
420 | { | 423 | { |
421 | QMessageBox::information( this, "Wellenreiter II", | 424 | QMessageBox::information( this, "Wellenreiter II", |
422 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 425 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
423 | return; | 426 | return; |
424 | } | 427 | } |
425 | 428 | ||
426 | // configure device | 429 | // configure device |
427 | ONetwork* net = ONetwork::instance(); | 430 | ONetwork* net = ONetwork::instance(); |
428 | 431 | ||
429 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 432 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
430 | 433 | ||
431 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 434 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
432 | 435 | ||
433 | // bring device UP | 436 | // bring device UP |
434 | if ( cardtype != DEVTYPE_FILE ) | 437 | if ( cardtype != DEVTYPE_FILE ) |
435 | { | 438 | { |
436 | iface->setUp( true ); | 439 | iface->setUp( true ); |
437 | if ( !iface->isUp() ) | 440 | if ( !iface->isUp() ) |
438 | { | 441 | { |
439 | QMessageBox::warning( this, "Wellenreiter II", | 442 | QMessageBox::warning( this, "Wellenreiter II", |
440 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 443 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
441 | return; | 444 | return; |
442 | } | 445 | } |
443 | } | 446 | } |
444 | // set monitor mode | 447 | // set monitor mode |
445 | bool usePrism = configwindow->usePrismHeader(); | 448 | bool usePrism = configwindow->usePrismHeader(); |
446 | 449 | ||
447 | switch ( cardtype ) | 450 | switch ( cardtype ) |
448 | { | 451 | { |
449 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 452 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
450 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 453 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
451 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 454 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
452 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 455 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
453 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 456 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
454 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 457 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
455 | default: assert( 0 ); // shouldn't reach this | 458 | default: assert( 0 ); // shouldn't reach this |
456 | } | 459 | } |
457 | 460 | ||
458 | // switch device into monitor mode | 461 | // switch device into monitor mode |
459 | if ( cardtype < DEVTYPE_FILE ) | 462 | if ( cardtype < DEVTYPE_FILE ) |
460 | { | 463 | { |
461 | if ( cardtype != DEVTYPE_MANUAL ) | 464 | if ( cardtype != DEVTYPE_MANUAL ) |
462 | iface->setMonitorMode( true ); | 465 | iface->setMonitorMode( true ); |
463 | if ( !iface->monitorMode() ) | 466 | if ( !iface->monitorMode() ) |
464 | { | 467 | { |
465 | if ( QMessageBox::warning( this, "Wellenreiter II", | 468 | if ( QMessageBox::warning( this, "Wellenreiter II", |
466 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 469 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
467 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 470 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
468 | return; | 471 | return; |
469 | } | 472 | } |
470 | } | 473 | } |
471 | 474 | ||
472 | // open GPS device | 475 | // open GPS device |
473 | if ( configwindow->enableGPS->isChecked() ) | 476 | if ( configwindow->enableGPS->isChecked() ) |
474 | { | 477 | { |
475 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 478 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
476 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 479 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
477 | } | 480 | } |
478 | 481 | ||
479 | // open pcap and start sniffing | 482 | // open pcap and start sniffing |
480 | if ( cardtype != DEVTYPE_FILE ) | 483 | if ( cardtype != DEVTYPE_FILE ) |
481 | { | 484 | { |
482 | pcap->open( interface ); | 485 | pcap->open( interface ); |
483 | 486 | ||
484 | if ( configwindow->writeCaptureFile->isChecked() ) | 487 | if ( configwindow->writeCaptureFile->isChecked() ) |
485 | { | 488 | { |
486 | QString dumpname( configwindow->captureFileName->text() ); | 489 | QString dumpname( configwindow->captureFileName->text() ); |
487 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 490 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
488 | dumpname.append( '-' ); | 491 | dumpname.append( '-' ); |
489 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 492 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
490 | dumpname.append( ".wellenreiter" ); | 493 | dumpname.append( ".wellenreiter" ); |
491 | pcap->openDumpFile( dumpname ); | 494 | pcap->openDumpFile( dumpname ); |
492 | } | 495 | } |
493 | else | 496 | else |
494 | { | 497 | { |
495 | pcap->open( interface ); | 498 | pcap->open( interface ); |
496 | } | 499 | } |
497 | } | 500 | } |
498 | else | 501 | else |
499 | { | 502 | { |
500 | pcap->open( QFile( interface ) ); | 503 | pcap->open( QFile( interface ) ); |
501 | } | 504 | } |
502 | 505 | ||
503 | if ( !pcap->isOpen() ) | 506 | if ( !pcap->isOpen() ) |
504 | { | 507 | { |
505 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 508 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
506 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 509 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
507 | return; | 510 | return; |
508 | } | 511 | } |
509 | 512 | ||
510 | // set capturer to non-blocking mode | 513 | // set capturer to non-blocking mode |
511 | pcap->setBlocking( false ); | 514 | pcap->setBlocking( false ); |
512 | 515 | ||
513 | // start channel hopper | 516 | // start channel hopper |
514 | if ( cardtype != DEVTYPE_FILE ) | 517 | if ( cardtype != DEVTYPE_FILE ) |
515 | { | 518 | { |
516 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 519 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
517 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 520 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
518 | } | 521 | } |
519 | 522 | ||
520 | if ( cardtype != DEVTYPE_FILE ) | 523 | if ( cardtype != DEVTYPE_FILE ) |
521 | { | 524 | { |
522 | // connect socket notifier and start channel hopper | 525 | // connect socket notifier and start channel hopper |
523 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 526 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
524 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 527 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
525 | } | 528 | } |
526 | else | 529 | else |
527 | { | 530 | { |
528 | // start timer for reading packets | 531 | // start timer for reading packets |
529 | startTimer( 100 ); | 532 | startTimer( 100 ); |
530 | } | 533 | } |
531 | 534 | ||
532 | logwindow->log( "(i) Started Scanning." ); | 535 | logwindow->log( "(i) Started Scanning." ); |
533 | sniffing = true; | 536 | sniffing = true; |
534 | 537 | ||
535 | #ifdef QWS | 538 | #ifdef QWS |
536 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 539 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
537 | { | 540 | { |
538 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 541 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
539 | } | 542 | } |
540 | #else | 543 | #else |
541 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 544 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
542 | #endif | 545 | #endif |
543 | 546 | ||
544 | emit( startedSniffing() ); | 547 | emit( startedSniffing() ); |
545 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 548 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
546 | else | 549 | else |
547 | { | 550 | { |
548 | assert( parent() ); | 551 | assert( parent() ); |
549 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 552 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
550 | } | 553 | } |
551 | } | 554 | } |
552 | 555 | ||
553 | 556 | ||
554 | void Wellenreiter::timerEvent( QTimerEvent* ) | 557 | void Wellenreiter::timerEvent( QTimerEvent* ) |
555 | { | 558 | { |
556 | qDebug( "Wellenreiter::timerEvent()" ); | 559 | qDebug( "Wellenreiter::timerEvent()" ); |
557 | OPacket* p = pcap->next(); | 560 | OPacket* p = pcap->next(); |
558 | if ( !p ) // no more packets available | 561 | if ( !p ) // no more packets available |
559 | { | 562 | { |
560 | stopClicked(); | 563 | stopClicked(); |
561 | } | 564 | } |
562 | else | 565 | else |
563 | { | 566 | { |
564 | receivePacket( p ); | 567 | receivePacket( p ); |
565 | delete p; | 568 | delete p; |
566 | } | 569 | } |
567 | } | 570 | } |
568 | 571 | ||
569 | 572 | ||
570 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 573 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
571 | { | 574 | { |
572 | #ifdef QWS | 575 | #ifdef QWS |
573 | if ( action == "TouchSound" ) | 576 | if ( action == "TouchSound" ) |
574 | ODevice::inst()->touchSound(); | 577 | ODevice::inst()->touchSound(); |
575 | else if ( action == "AlarmSound" ) | 578 | else if ( action == "AlarmSound" ) |
576 | ODevice::inst()->alarmSound(); | 579 | ODevice::inst()->alarmSound(); |
577 | else if ( action == "KeySound" ) | 580 | else if ( action == "KeySound" ) |
578 | ODevice::inst()->keySound(); | 581 | ODevice::inst()->keySound(); |
579 | else if ( action == "LedOn" ) | 582 | else if ( action == "LedOn" ) |
580 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 583 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
581 | else if ( action == "LedOff" ) | 584 | else if ( action == "LedOff" ) |
582 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 585 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
583 | else if ( action == "LogMessage" ) | 586 | else if ( action == "LogMessage" ) |
584 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 587 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
585 | else if ( action == "MessageBox" ) | 588 | else if ( action == "MessageBox" ) |
586 | QMessageBox::information( this, "Notification!", | 589 | QMessageBox::information( this, "Notification!", |
587 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 590 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
588 | #else | 591 | #else |
589 | #warning Actions do not work with Qt/X11 yet | 592 | #warning Actions do not work with Qt/X11 yet |
590 | #endif | 593 | #endif |
591 | } | 594 | } |
592 | 595 | ||
593 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 596 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
594 | { | 597 | { |
595 | #ifdef QWS | 598 | #ifdef QWS |
596 | if ( !iface ) | 599 | if ( !iface ) |
597 | { | 600 | { |
598 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 601 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
599 | return; | 602 | return; |
600 | } | 603 | } |
601 | 604 | ||
602 | if ( sniffing ) | 605 | if ( sniffing ) |
603 | { | 606 | { |
604 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 607 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
605 | return; | 608 | return; |
606 | } | 609 | } |
607 | 610 | ||
608 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 611 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
609 | (const char*) iface->name(), | 612 | (const char*) iface->name(), |
610 | (const char*) type, | 613 | (const char*) type, |
611 | (const char*) essid, | 614 | (const char*) essid, |
612 | channel, | 615 | channel, |
613 | (const char*) macaddr ); | 616 | (const char*) macaddr ); |
614 | 617 | ||
615 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 618 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
616 | int count = 3; | 619 | int count = 3; |
617 | qDebug("sending %d messages",count); | 620 | qDebug("sending %d messages",count); |
618 | msg << QString("count") << QString::number(count); | 621 | msg << QString("count") << QString::number(count); |
619 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 622 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); |
620 | msg << QString(iface->name()) << QString("Mode") << type; | 623 | msg << QString(iface->name()) << QString("Mode") << type; |
621 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 624 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); |
622 | msg << QString(iface->name()) << QString("ESSID") << essid; | 625 | msg << QString(iface->name()) << QString("ESSID") << essid; |
623 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 626 | qDebug("msg >%s< channel >%d<", iface->name(),channel); |
624 | msg << QString(iface->name()) << QString("Channel") << channel; | 627 | msg << QString(iface->name()) << QString("Channel") << channel; |
625 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 628 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
626 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 629 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
627 | #else | 630 | #else |
628 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 631 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
629 | #endif | 632 | #endif |
630 | 633 | ||
631 | } | 634 | } |
632 | 635 | ||