-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 8c2015e..f24e09f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,569 +1,590 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Wellenreiter II. | 4 | ** This file is part of Wellenreiter II. |
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 | /* OPIE */ | 20 | /* OPIE */ |
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #else | 25 | #else |
26 | #include "resource.h" | 26 | #include "resource.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qcursor.h> | 31 | #include <qcursor.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | 35 | ||
36 | /* STD */ | 36 | /* STD */ |
37 | #include <assert.h> | 37 | #include <assert.h> |
38 | 38 | ||
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | using namespace Opie::Net; | 41 | using namespace Opie::Net; |
42 | 42 | ||
43 | const int col_type = 0; | 43 | const int col_type = 0; |
44 | const int col_essid = 0; | 44 | const int col_essid = 0; |
45 | const int col_sig = 1; | 45 | const int col_sig = 1; |
46 | const int col_ap = 2; | 46 | const int col_ap = 2; |
47 | const int col_channel = 3; | 47 | const int col_channel = 3; |
48 | const int col_wep = 4; | 48 | const int col_wep = 4; |
49 | const int col_traffic = 5; | 49 | const int col_traffic = 5; |
50 | const int col_ip = 6; | 50 | const int col_ip = 6; |
51 | const int col_manuf = 7; | 51 | const int col_manuf = 7; |
52 | const int col_firstseen = 8; | 52 | const int col_firstseen = 8; |
53 | const int col_lastseen = 9; | 53 | const int col_lastseen = 9; |
54 | const int col_location = 10; | 54 | const int col_location = 10; |
55 | 55 | ||
56 | #define DEBUG | 56 | #define DEBUG |
57 | 57 | ||
58 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 58 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
59 | :OListView( parent, name ) | 59 | :OListView( parent, name ) |
60 | { | 60 | { |
61 | setFrameShape( QListView::StyledPanel ); | 61 | setFrameShape( QListView::StyledPanel ); |
62 | setFrameShadow( QListView::Sunken ); | 62 | setFrameShadow( QListView::Sunken ); |
63 | 63 | ||
64 | addColumn( tr( "Net/Station" ) ); | 64 | addColumn( tr( "Net/Station" ) ); |
65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 65 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
66 | addColumn( tr( "#" ) ); | 66 | addColumn( tr( "#" ) ); |
67 | setColumnAlignment( col_sig, AlignCenter ); | 67 | setColumnAlignment( col_sig, AlignCenter ); |
68 | addColumn( tr( "MAC" ) ); | 68 | addColumn( tr( "MAC" ) ); |
69 | setColumnAlignment( col_ap, AlignCenter ); | 69 | setColumnAlignment( col_ap, AlignCenter ); |
70 | addColumn( tr( "Chn" ) ); | 70 | addColumn( tr( "Chn" ) ); |
71 | setColumnAlignment( col_channel, AlignCenter ); | 71 | setColumnAlignment( col_channel, AlignCenter ); |
72 | addColumn( tr( "W" ) ); | 72 | addColumn( tr( "W" ) ); |
73 | setColumnAlignment( col_wep, AlignCenter ); | 73 | setColumnAlignment( col_wep, AlignCenter ); |
74 | addColumn( tr( "T" ) ); | 74 | addColumn( tr( "T" ) ); |
75 | setColumnAlignment( col_traffic, AlignCenter ); | 75 | setColumnAlignment( col_traffic, AlignCenter ); |
76 | addColumn( tr( "IP" ) ); | 76 | addColumn( tr( "IP" ) ); |
77 | setColumnAlignment( col_ip, AlignCenter ); | 77 | setColumnAlignment( col_ip, AlignCenter ); |
78 | addColumn( tr( "Manufacturer" ) ); | 78 | addColumn( tr( "Manufacturer" ) ); |
79 | setColumnAlignment( col_manuf, AlignCenter ); | 79 | setColumnAlignment( col_manuf, AlignCenter ); |
80 | addColumn( tr( "First Seen" ) ); | 80 | addColumn( tr( "First Seen" ) ); |
81 | setColumnAlignment( col_firstseen, AlignCenter ); | 81 | setColumnAlignment( col_firstseen, AlignCenter ); |
82 | addColumn( tr( "Last Seen" ) ); | 82 | addColumn( tr( "Last Seen" ) ); |
83 | setColumnAlignment( col_lastseen, AlignCenter ); | 83 | setColumnAlignment( col_lastseen, AlignCenter ); |
84 | addColumn( tr( "Location" ) ); | 84 | addColumn( tr( "Location" ) ); |
85 | setColumnAlignment( col_location, AlignCenter ); | 85 | setColumnAlignment( col_location, AlignCenter ); |
86 | setRootIsDecorated( true ); | 86 | setRootIsDecorated( true ); |
87 | setAllColumnsShowFocus( true ); | 87 | setAllColumnsShowFocus( true ); |
88 | 88 | ||
89 | connect( this, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), | 89 | connect( this, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 90 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
91 | 91 | ||
92 | #ifdef QWS | 92 | #ifdef QWS |
93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 93 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | MScanListView::~MScanListView() | 99 | MScanListView::~MScanListView() |
100 | { | 100 | { |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | OListViewItem* MScanListView::childFactory() | 104 | OListViewItem* MScanListView::childFactory() |
105 | { | 105 | { |
106 | return new MScanListItem( this ); | 106 | return new MScanListItem( this ); |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | void MScanListView::serializeTo( QDataStream& s) const | 110 | void MScanListView::serializeTo( QDataStream& s) const |
111 | { | 111 | { |
112 | odebug << "serializing MScanListView" << oendl; | 112 | odebug << "serializing MScanListView" << oendl; |
113 | OListView::serializeTo( s ); | 113 | OListView::serializeTo( s ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void MScanListView::serializeFrom( QDataStream& s) | 117 | void MScanListView::serializeFrom( QDataStream& s) |
118 | { | 118 | { |
119 | odebug << "serializing MScanListView" << oendl; | 119 | odebug << "serializing MScanListView" << oendl; |
120 | OListView::serializeFrom( s ); | 120 | OListView::serializeFrom( s ); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | void MScanListView::addNewItem( const QString& type, | 124 | void MScanListView::addNewItem( const QString& type, |
125 | const QString& essid, | 125 | const QString& essid, |
126 | const OMacAddress& mac, | 126 | const OMacAddress& mac, |
127 | bool wep, | 127 | bool wep, |
128 | int channel, | 128 | int channel, |
129 | int signal, | 129 | int signal, |
130 | const GpsLocation& loc, | 130 | const GpsLocation& loc, |
131 | bool probe ) | 131 | bool probe ) |
132 | { | 132 | { |
133 | QString macaddr = mac.toString(true); | 133 | QString macaddr = mac.toString(true); |
134 | 134 | ||
135 | #ifdef DEBUG | 135 | #ifdef DEBUG |
136 | odebug << "MScanList::addNewItem( " << type << " / " | 136 | odebug << "MScanList::addNewItem( " << type << " / " |
137 | << essid << " / " << macaddr | 137 | << essid << " / " << macaddr |
138 | << " [" << channel << "]" << oendl; | 138 | << " [" << channel << "]" << oendl; |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | // search, if we already have seen this net | 141 | // search, if we already have seen this net |
142 | 142 | ||
143 | QString s; | 143 | QString s; |
144 | MScanListItem* network; | 144 | MScanListItem* network; |
145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 145 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
146 | 146 | ||
147 | while ( item && ( item->text( col_essid ) != essid ) ) | 147 | while ( item && ( item->text( col_essid ) != essid ) ) |
148 | { | 148 | { |
149 | #ifdef DEBUG | 149 | #ifdef DEBUG |
150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; | 150 | odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; |
151 | #endif | 151 | #endif |
152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
153 | } | 153 | } |
154 | if ( item ) | 154 | if ( item ) |
155 | { | 155 | { |
156 | // we have already seen this net, check all childs if MAC exists | 156 | // we have already seen this net, check all childs if MAC exists |
157 | 157 | ||
158 | network = item; | 158 | network = item; |
159 | 159 | ||
160 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 160 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
161 | assert( item ); // this shouldn't fail | 161 | assert( item ); // this shouldn't fail |
162 | 162 | ||
163 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 163 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
164 | { | 164 | { |
165 | #ifdef DEBUG | 165 | #ifdef DEBUG |
166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; | 166 | odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; |
167 | #endif | 167 | #endif |
168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 168 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
169 | } | 169 | } |
170 | 170 | ||
171 | if ( item ) | 171 | if ( item ) |
172 | { | 172 | { |
173 | // we have already seen this item, it's a dupe | 173 | // we have already seen this item, it's a dupe |
174 | #ifdef DEBUG | 174 | #ifdef DEBUG |
175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; | 175 | odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; |
176 | #endif | 176 | #endif |
177 | item->receivedBeacon(); | 177 | item->receivedBeacon(); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); | 183 | s = QString( "(i) New network: ESSID '%1'" ).arg( essid ); |
184 | MLogWindow::logwindow()->log( s ); | 184 | MLogWindow::logwindow()->log( s ); |
185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 185 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | // insert new station as child from network | 189 | // insert new station as child from network |
190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 190 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
191 | 191 | ||
192 | #ifdef DEBUG | 192 | #ifdef DEBUG |
193 | odebug << "inserting new station " << macaddr << "" << oendl; | 193 | odebug << "inserting new station " << macaddr << "" << oendl; |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 196 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
197 | station->setManufacturer( mac.manufacturer() ); | 197 | station->setManufacturer( mac.manufacturer() ); |
198 | station->setLocation( loc.dmsPosition() ); | 198 | station->setLocation( loc.dmsPosition() ); |
199 | 199 | ||
200 | if ( type == "managed" ) | 200 | if ( type == "managed" ) |
201 | { | 201 | { |
202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); | 202 | s = QString( "(i) New Access Point in '%1' [%2]" ).arg( essid ).arg( channel ); |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); | 206 | s = QString( "(i) New AdHoc station in '%1' [%2]" ).arg( essid ).arg( channel ); |
207 | } | 207 | } |
208 | MLogWindow::logwindow()->log( s ); | 208 | MLogWindow::logwindow()->log( s ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 212 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
213 | { | 213 | { |
214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 214 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
215 | 215 | ||
216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 216 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
217 | { | 217 | { |
218 | #ifdef DEBUG | 218 | #ifdef DEBUG |
219 | odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; | 219 | odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; |
220 | #endif | 220 | #endif |
221 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 221 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( subitem ) | 224 | if ( subitem ) |
225 | { | 225 | { |
226 | // we have already seen this item, it's a dupe | 226 | // we have already seen this item, it's a dupe |
227 | #ifdef DEBUG | 227 | #ifdef DEBUG |
228 | odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; | 228 | odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; |
229 | #endif | 229 | #endif |
230 | subitem->receivedBeacon(); //FIXME: sent data bit | 230 | subitem->receivedBeacon(); //FIXME: sent data bit |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | 233 | ||
234 | // Hey, it seems to be a new item :-D | 234 | // Hey, it seems to be a new item :-D |
235 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 235 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
236 | station->setManufacturer( addr.manufacturer() ); | 236 | station->setManufacturer( addr.manufacturer() ); |
237 | 237 | ||
238 | QString s; | 238 | QString s; |
239 | if ( type == "station" ) | 239 | if ( type == "station" ) |
240 | { | 240 | { |
241 | s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) ); | 241 | s = QString( "(i) New Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
242 | } | 242 | } |
243 | else | 243 | else |
244 | { | 244 | { |
245 | s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) ); | 245 | s = QString( "(i) New Wireless Station in '%1' [xx]" ).arg( network->text( col_essid ) ); |
246 | } | 246 | } |
247 | MLogWindow::logwindow()->log( s ); | 247 | MLogWindow::logwindow()->log( s ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 251 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
252 | { | 252 | { |
253 | odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; | 253 | odebug << "WDSTraffic: " << viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; |
254 | QString s; | 254 | QString s; |
255 | // MScanListItem* network; | 255 | // MScanListItem* network; |
256 | 256 | ||
257 | QListViewItemIterator it( this ); | 257 | QListViewItemIterator it( this ); |
258 | while ( it.current() && | 258 | while ( it.current() && |
259 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 259 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
260 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 260 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
261 | 261 | ||
262 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 262 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
263 | 263 | ||
264 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 264 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
265 | { | 265 | { |
266 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 266 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
267 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 267 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
268 | } | 268 | } |
269 | else | 269 | else |
270 | { | 270 | { |
271 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; | 271 | odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; |
272 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 272 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) | 277 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
278 | { | 278 | { |
279 | QString s; | 279 | QString s; |
280 | // MScanListItem* network; | 280 | // MScanListItem* network; |
281 | 281 | ||
282 | QListViewItemIterator it( this ); | 282 | QListViewItemIterator it( this ); |
283 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 283 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
284 | 284 | ||
285 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 285 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
286 | 286 | ||
287 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 287 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
288 | { | 288 | { |
289 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 289 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
290 | } | 290 | } |
291 | else | 291 | else |
292 | { | 292 | { |
293 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; | 293 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
294 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 294 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
295 | 295 | ||
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) | 300 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& /*to*/, const OMacAddress& via ) |
301 | { | 301 | { |
302 | QString s; | 302 | QString s; |
303 | // MScanListItem* network; | 303 | // MScanListItem* network; |
304 | 304 | ||
305 | QListViewItemIterator it( this ); | 305 | QListViewItemIterator it( this ); |
306 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 306 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
307 | 307 | ||
308 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 308 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
309 | 309 | ||
310 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 310 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
311 | { | 311 | { |
312 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 312 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
313 | } | 313 | } |
314 | else | 314 | else |
315 | { | 315 | { |
316 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; | 316 | odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; |
317 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 317 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ ) | 322 | void MScanListView::IBSStraffic( const OMacAddress& /*from*/, const OMacAddress& /*to*/, const OMacAddress& /*via*/ ) |
323 | { | 323 | { |
324 | owarn << "D'oh! Not yet implemented..." << oendl; | 324 | owarn << "D'oh! Not yet implemented..." << oendl; |
325 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 325 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 329 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
330 | { | 330 | { |
331 | odebug << "identify " << macaddr.toString() << " = " << ip << "" << oendl; | 331 | odebug << "identify " << macaddr.toString() << " = " << ip << "" << oendl; |
332 | 332 | ||
333 | QListViewItemIterator it( this ); | 333 | QListViewItemIterator it( this ); |
334 | for ( ; it.current(); ++it ) | 334 | for ( ; it.current(); ++it ) |
335 | { | 335 | { |
336 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 336 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
337 | { | 337 | { |
338 | it.current()->setText( col_ip, ip ); | 338 | it.current()->setText( col_ip, ip ); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 342 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
343 | MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" ) | 343 | MLogWindow::logwindow()->log( QString( "WARNING: Unhandled identification %1 = %2!" ) |
344 | .arg( macaddr.toString() ).arg( ip ) ); | 344 | .arg( macaddr.toString() ).arg( ip ) ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 348 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
349 | { | 349 | { |
350 | odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << ip << "" << oendl; | 350 | odebug << "addService '" << name << "', Server = " << macaddr.toString() << " = " << ip << "" << oendl; |
351 | 351 | ||
352 | //TODO: Refactor that out, we need it all over the place. | 352 | //TODO: Refactor that out, we need it all over the place. |
353 | // Best to do it in a more comfortable abstraction in OListView | 353 | // Best to do it in a more comfortable abstraction in OListView |
354 | // (Hmm, didn't I already start something in this direction?) | 354 | // (Hmm, didn't I already start something in this direction?) |
355 | 355 | ||
356 | QListViewItemIterator it( this ); | 356 | QListViewItemIterator it( this ); |
357 | for ( ; it.current(); ++it ) | 357 | for ( ; it.current(); ++it ) |
358 | { | 358 | { |
359 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 359 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
360 | { | 360 | { |
361 | 361 | ||
362 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 362 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
363 | 363 | ||
364 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 364 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
365 | { | 365 | { |
366 | #ifdef DEBUG | 366 | #ifdef DEBUG |
367 | odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; | 367 | odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; |
368 | #endif | 368 | #endif |
369 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 369 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
370 | } | 370 | } |
371 | 371 | ||
372 | if ( subitem ) | 372 | if ( subitem ) |
373 | { | 373 | { |
374 | // we have already seen this item, it's a dupe | 374 | // we have already seen this item, it's a dupe |
375 | #ifdef DEBUG | 375 | #ifdef DEBUG |
376 | odebug << "" << name << " is a dupe - ignoring..." << oendl; | 376 | odebug << "" << name << " is a dupe - ignoring..." << oendl; |
377 | #endif | 377 | #endif |
378 | subitem->receivedBeacon(); //FIXME: sent data bit | 378 | subitem->receivedBeacon(); //FIXME: sent data bit |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | 381 | ||
382 | // never seen that - add new item | 382 | // never seen that - add new item |
383 | 383 | ||
384 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 384 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
385 | item->setText( col_essid, name ); | 385 | item->setText( col_essid, name ); |
386 | 386 | ||
387 | return; | 387 | return; |
388 | } | 388 | } |
389 | } | 389 | } |
390 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; | 390 | odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; |
391 | MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!") | 391 | MLogWindow::logwindow()->log( QString("WARNING: Unhandled service addition %s = %s!") |
392 | .arg( macaddr.toString() ).arg( ip ) ); | 392 | .arg( macaddr.toString() ).arg( ip ) ); |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 396 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
397 | { | 397 | { |
398 | if ( !item ) return; | 398 | if ( !item ) return; |
399 | 399 | ||
400 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 400 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
401 | 401 | ||
402 | odebug << "contextMenuRequested on item '" << itm->text(0) << "' (" | 402 | odebug << "contextMenuRequested on item '" << itm->text(0) << "' (" |
403 | << itm->type << ") in column: '" << col << "'" << oendl; | 403 | << itm->type << ") in column: '" << col << "'" << oendl; |
404 | 404 | ||
405 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 405 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
406 | { | 406 | { |
407 | QString entry = QString( "&Join %1 Net '%2'..." ).arg( itm->type ).arg( itm->essid() ); | 407 | QString entry = QString( "&Join %1 Net '%2'..." ).arg( itm->type ).arg( itm->essid() ); |
408 | 408 | ||
409 | QPopupMenu m( this ); | 409 | QPopupMenu m( this ); |
410 | m.insertItem( entry, 37773, 0 ); | 410 | m.insertItem( entry, 37773, 0 ); |
411 | int result = m.exec( QCursor::pos() ); | 411 | int result = m.exec( QCursor::pos() ); |
412 | if ( result == 37773 ) | 412 | if ( result == 37773 ) |
413 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 413 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | //============================================================ | 417 | //============================================================ |
418 | // MScanListItem | 418 | // MScanListItem |
419 | //============================================================ | 419 | //============================================================ |
420 | 420 | ||
421 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 421 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
422 | bool wep, int channel, int signal, bool probed ) | 422 | bool wep, int channel, int signal, bool probed ) |
423 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 423 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
424 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 424 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
425 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 425 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
426 | { | 426 | { |
427 | #ifdef DEBUG | 427 | #ifdef DEBUG |
428 | odebug << "creating scanlist item" << oendl; | 428 | odebug << "creating scanlist item" << oendl; |
429 | #endif | 429 | #endif |
430 | 430 | ||
431 | if ( WellenreiterConfigWindow::instance() ) | 431 | if ( WellenreiterConfigWindow::instance() ) |
432 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 432 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
433 | 433 | ||
434 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 434 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
435 | } | 435 | } |
436 | 436 | ||
437 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 437 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
438 | bool wep, int channel, int signal ) | 438 | bool wep, int channel, int signal ) |
439 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 439 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
440 | { | 440 | { |
441 | #ifdef DEBUG | 441 | #ifdef DEBUG |
442 | odebug << "creating scanlist item" << oendl; | 442 | odebug << "creating scanlist item" << oendl; |
443 | #endif | 443 | #endif |
444 | if ( WellenreiterConfigWindow::instance() ) | 444 | if ( WellenreiterConfigWindow::instance() ) |
445 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 445 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
446 | 446 | ||
447 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 447 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
448 | } | 448 | } |
449 | 449 | ||
450 | const QString& MScanListItem::essid() const | 450 | const QString& MScanListItem::essid() const |
451 | { | 451 | { |
452 | if ( type == "network" ) | 452 | if ( type == "network" ) |
453 | return _essid; | 453 | return _essid; |
454 | else | 454 | else |
455 | return ( (MScanListItem*) parent() )->essid(); | 455 | return ( (MScanListItem*) parent() )->essid(); |
456 | } | 456 | } |
457 | 457 | ||
458 | OListViewItem* MScanListItem::childFactory() | 458 | OListViewItem* MScanListItem::childFactory() |
459 | { | 459 | { |
460 | return new MScanListItem( this ); | 460 | return new MScanListItem( this ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void MScanListItem::serializeTo( QDataStream& s ) const | 463 | void MScanListItem::serializeTo( QDataStream& s ) const |
464 | { | 464 | { |
465 | #ifdef DEBUG | 465 | #ifdef DEBUG |
466 | odebug << "serializing MScanListItem" << oendl; | 466 | odebug << "serializing MScanListItem" << oendl; |
467 | #endif | 467 | #endif |
468 | OListViewItem::serializeTo( s ); | 468 | OListViewItem::serializeTo( s ); |
469 | 469 | ||
470 | s << _type; | 470 | s << _type; |
471 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 471 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
472 | } | 472 | } |
473 | 473 | ||
474 | void MScanListItem::serializeFrom( QDataStream& s ) | 474 | void MScanListItem::serializeFrom( QDataStream& s ) |
475 | { | 475 | { |
476 | #ifdef DEBUG | 476 | #ifdef DEBUG |
477 | odebug << "serializing MScanListItem" << oendl; | 477 | odebug << "serializing MScanListItem" << oendl; |
478 | #endif | 478 | #endif |
479 | OListViewItem::serializeFrom( s ); | 479 | OListViewItem::serializeFrom( s ); |
480 | 480 | ||
481 | Q_UINT8 wep; | 481 | Q_UINT8 wep; |
482 | s >> _type; | 482 | s >> _type; |
483 | s >> wep; | 483 | s >> wep; |
484 | _wep = (wep == 'y'); | 484 | _wep = (wep == 'y'); |
485 | 485 | ||
486 | QString name = QString( "wellenreiter/"+ _type ); | 486 | QString name = QString( "wellenreiter/"+ _type ); |
487 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 487 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
488 | if ( _wep ) | 488 | if ( _wep ) |
489 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 489 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
490 | listView()->triggerUpdate(); | 490 | listView()->triggerUpdate(); |
491 | } | 491 | } |
492 | 492 | ||
493 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 493 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
494 | { | 494 | { |
495 | #ifdef DEBUG | 495 | #ifdef DEBUG |
496 | odebug << "decorating scanlist item " << type << " / " | 496 | odebug << "decorating scanlist item " << type << " / " |
497 | << essid << " / " << macaddr | 497 | << essid << " / " << macaddr |
498 | << "[" << channel << "]" << oendl; | 498 | << "[" << channel << "]" << oendl; |
499 | #endif | 499 | #endif |
500 | 500 | ||
501 | // set icon for managed or adhoc mode | 501 | // set icon for managed or adhoc mode |
502 | QString name; | 502 | QString name; |
503 | name.sprintf( "wellenreiter/"+ type ); | 503 | name.sprintf( "wellenreiter/"+ type ); |
504 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 504 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
505 | 505 | ||
506 | // special case for probed networks FIXME: This is ugly at present | 506 | // special case for probed networks FIXME: This is ugly at present |
507 | if ( type == "network" && probed ) | 507 | if ( type == "network" && probed ) |
508 | { | 508 | { |
509 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | 509 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); |
510 | } | 510 | } |
511 | 511 | ||
512 | // set icon for wep (wireless encryption protocol) | 512 | // set icon for wep (wireless encryption protocol) |
513 | if ( wep ) | 513 | if ( wep ) |
514 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 514 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
515 | 515 | ||
516 | // set channel and signal text | 516 | // set channel and signal text |
517 | 517 | ||
518 | if ( signal != -1 ) | 518 | if ( signal != -1 ) |
519 | setText( col_sig, QString::number( signal ) ); | 519 | setText( col_sig, QString::number( signal ) ); |
520 | if ( channel != -1 ) | 520 | if ( channel != -1 ) |
521 | setText( col_channel, QString::number( channel ) ); | 521 | setText( col_channel, QString::number( channel ) ); |
522 | 522 | ||
523 | setText( col_firstseen, QTime::currentTime().toString() ); | 523 | setText( col_firstseen, QTime::currentTime().toString() ); |
524 | //setText( col_lastseen, QTime::currentTime().toString() ); | 524 | //setText( col_lastseen, QTime::currentTime().toString() ); |
525 | 525 | ||
526 | listView()->triggerUpdate(); | 526 | listView()->triggerUpdate(); |
527 | 527 | ||
528 | this->type = type; | 528 | this->type = type; |
529 | _type = type; | 529 | _type = type; |
530 | _essid = essid; | 530 | _essid = essid; |
531 | _macaddr = macaddr; | 531 | _macaddr = macaddr; |
532 | _channel = channel; | 532 | _channel = channel; |
533 | _beacons = 1; | 533 | _beacons = 1; |
534 | _signal = 0; | 534 | _signal = 0; |
535 | 535 | ||
536 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 536 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
537 | { | 537 | { |
538 | listView()->ensureItemVisible( this ); | 538 | listView()->ensureItemVisible( this ); |
539 | } | 539 | } |
540 | 540 | ||
541 | } | 541 | } |
542 | 542 | ||
543 | 543 | ||
544 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 544 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
545 | { | 545 | { |
546 | setText( col_manuf, manufacturer ); | 546 | setText( col_manuf, manufacturer ); |
547 | } | 547 | } |
548 | 548 | ||
549 | 549 | ||
550 | void MScanListItem::setLocation( const QString& location ) | 550 | void MScanListItem::setLocation( const QString& location ) |
551 | { | 551 | { |
552 | setText( col_location, location ); | 552 | setText( col_location, location ); |
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 | odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; | 560 | odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; |
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 | ||
570 | QString MScanListItem::key( int id, bool b )const { | ||
571 | QString str; | ||
572 | |||
573 | /* | ||
574 | * Pad the amount of received packages, number | ||
575 | * of the channel. | ||
576 | */ | ||
577 | switch( id ) { | ||
578 | case col_sig: | ||
579 | str = text(col_sig).rightJustify( 20, '0' ); | ||
580 | break; | ||
581 | case col_channel: | ||
582 | str = text(col_channel).rightJustify( 2, '0' ); | ||
583 | break; | ||
584 | default: | ||
585 | str = Opie::Ui::OListViewItem::key( id, b ); | ||
586 | break; | ||
587 | } | ||
588 | |||
589 | return str; | ||
590 | } | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 6a80f70..8b3814a 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -1,140 +1,142 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Wellenreiter II. | 4 | ** This file is part of Wellenreiter II. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef SCANLIST_H | 16 | #ifndef SCANLIST_H |
17 | #define SCANLIST_H | 17 | #define SCANLIST_H |
18 | 18 | ||
19 | #include "gps.h" | 19 | #include "gps.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/olistview.h> | 22 | #include <opie2/olistview.h> |
23 | #include <opie2/onetutils.h> | 23 | #include <opie2/onetutils.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | 27 | ||
28 | class QString; | 28 | class QString; |
29 | class MScanListItem; | 29 | class MScanListItem; |
30 | 30 | ||
31 | class MScanListView: public Opie::Ui::OListView | 31 | class MScanListView: public Opie::Ui::OListView |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | public: | 35 | public: |
36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | 36 | MScanListView( QWidget* parent = 0, const char* name = 0 ); |
37 | virtual ~MScanListView(); | 37 | virtual ~MScanListView(); |
38 | 38 | ||
39 | virtual Opie::Ui::OListViewItem* childFactory(); | 39 | virtual Opie::Ui::OListViewItem* childFactory(); |
40 | virtual void serializeTo( QDataStream& s ) const; | 40 | virtual void serializeTo( QDataStream& s ) const; |
41 | virtual void serializeFrom( QDataStream& s ); | 41 | virtual void serializeFrom( QDataStream& s ); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | void addNewItem( const QString& type, const QString&, const Opie::Net::OMacAddress&, bool, int, int, const GpsLocation&, bool = false ); | 44 | void addNewItem( const QString& type, const QString&, const Opie::Net::OMacAddress&, bool, int, int, const GpsLocation&, bool = false ); |
45 | void addService( const QString& name, const Opie::Net::OMacAddress& macaddr, const QString& ip ); | 45 | void addService( const QString& name, const Opie::Net::OMacAddress& macaddr, const QString& ip ); |
46 | 46 | ||
47 | void fromDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); | 47 | void fromDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); |
48 | void toDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); | 48 | void toDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); |
49 | void WDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& viaFrom, const Opie::Net::OMacAddress& viaTo ); | 49 | void WDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& viaFrom, const Opie::Net::OMacAddress& viaTo ); |
50 | void IBSStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); | 50 | void IBSStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via ); |
51 | 51 | ||
52 | void identify( const Opie::Net::OMacAddress&, const QString& ipaddr ); | 52 | void identify( const Opie::Net::OMacAddress&, const QString& ipaddr ); |
53 | 53 | ||
54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); | 54 | void contextMenuRequested( QListViewItem* item, const QPoint&, int ); |
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); | 57 | void rightButtonClicked(QListViewItem*,const QPoint&,int); |
58 | void joinNetwork( const QString&, const QString&, int, const QString& ); | 58 | void joinNetwork( const QString&, const QString&, int, const QString& ); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | void addIfNotExisting( MScanListItem* parent, const Opie::Net::OMacAddress& addr, const QString& type = "station" ); | 61 | void addIfNotExisting( MScanListItem* parent, const Opie::Net::OMacAddress& addr, const QString& type = "station" ); |
62 | 62 | ||
63 | }; | 63 | }; |
64 | 64 | ||
65 | //****************************** MScanListItem **************************************************************** | 65 | //****************************** MScanListItem **************************************************************** |
66 | 66 | ||
67 | class MScanListItem: public Opie::Ui::OListViewItem | 67 | class MScanListItem: public Opie::Ui::OListViewItem |
68 | { | 68 | { |
69 | public: | 69 | public: |
70 | MScanListItem::MScanListItem( QListView* parent, | 70 | MScanListItem::MScanListItem( QListView* parent, |
71 | const QString& type = "unknown", | 71 | const QString& type = "unknown", |
72 | const QString& essid = "unknown", | 72 | const QString& essid = "unknown", |
73 | const QString& macaddr = "unknown", | 73 | const QString& macaddr = "unknown", |
74 | bool wep = false, | 74 | bool wep = false, |
75 | int channel = 0, | 75 | int channel = 0, |
76 | int signal = 0, | 76 | int signal = 0, |
77 | bool probed = false ); | 77 | bool probed = false ); |
78 | 78 | ||
79 | MScanListItem::MScanListItem( QListViewItem* parent, | 79 | MScanListItem::MScanListItem( QListViewItem* parent, |
80 | const QString& type = "unknown", | 80 | const QString& type = "unknown", |
81 | const QString& essid = "unknown", | 81 | const QString& essid = "unknown", |
82 | const QString& macaddr = "unknown", | 82 | const QString& macaddr = "unknown", |
83 | bool wep = false, | 83 | bool wep = false, |
84 | int channel = 0, | 84 | int channel = 0, |
85 | int signal = 0 ); | 85 | int signal = 0 ); |
86 | 86 | ||
87 | 87 | ||
88 | protected: | 88 | protected: |
89 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ); | 89 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ); |
90 | 90 | ||
91 | public: | 91 | public: |
92 | QString type; | 92 | QString type; |
93 | 93 | ||
94 | public: | 94 | public: |
95 | //const QString& type() { return _type; }; | 95 | //const QString& type() { return _type; }; |
96 | const QString& essid() const; | 96 | const QString& essid() const; |
97 | const QString& macaddr() { return _macaddr; }; | 97 | const QString& macaddr() { return _macaddr; }; |
98 | bool wep() { return _wep; }; | 98 | bool wep() { return _wep; }; |
99 | int channel() { return _channel; }; | 99 | int channel() { return _channel; }; |
100 | int signal() { return _signal; }; | 100 | int signal() { return _signal; }; |
101 | int beacons() { return _beacons; }; | 101 | int beacons() { return _beacons; }; |
102 | 102 | ||
103 | void setSignal( int signal ) { /* TODO */ }; | 103 | void setSignal( int signal ) { /* TODO */ }; |
104 | void receivedBeacon(); | 104 | void receivedBeacon(); |
105 | 105 | ||
106 | void setManufacturer( const QString& manufacturer ); | 106 | void setManufacturer( const QString& manufacturer ); |
107 | void setLocation( const QString& location ); | 107 | void setLocation( const QString& location ); |
108 | 108 | ||
109 | virtual Opie::Ui::OListViewItem* childFactory(); | 109 | virtual Opie::Ui::OListViewItem* childFactory(); |
110 | virtual void serializeTo( QDataStream& s ) const; | 110 | virtual void serializeTo( QDataStream& s ) const; |
111 | virtual void serializeFrom( QDataStream& s ); | 111 | virtual void serializeFrom( QDataStream& s ); |
112 | 112 | ||
113 | virtual QString key( int id, bool )const; | ||
114 | |||
113 | private: | 115 | private: |
114 | QString _type; | 116 | QString _type; |
115 | QString _essid; | 117 | QString _essid; |
116 | QString _macaddr; | 118 | QString _macaddr; |
117 | bool _wep; | 119 | bool _wep; |
118 | int _channel; | 120 | int _channel; |
119 | int _signal; | 121 | int _signal; |
120 | int _beacons; | 122 | int _beacons; |
121 | 123 | ||
122 | }; | 124 | }; |
123 | 125 | ||
124 | //****************************** MScanListViewFactory **************************************************************** | 126 | //****************************** MScanListViewFactory **************************************************************** |
125 | 127 | ||
126 | /* | 128 | /* |
127 | 129 | ||
128 | class MScanListViewFactory : public Opie::Ui::OListViewFactory | 130 | class MScanListViewFactory : public Opie::Ui::OListViewFactory |
129 | { | 131 | { |
130 | public: | 132 | public: |
131 | virtual QListView* listViewFactory(); | 133 | virtual QListView* listViewFactory(); |
132 | virtual QListViewItem* listViewItemFactory( QListView* lv ); | 134 | virtual QListViewItem* listViewItemFactory( QListView* lv ); |
133 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); | 135 | virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); |
134 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); | 136 | virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); |
135 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); | 137 | virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); |
136 | } | 138 | } |
137 | */ | 139 | */ |
138 | 140 | ||
139 | #endif | 141 | #endif |
140 | 142 | ||