Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1cf49e0..3a6aa15 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -32,51 +32,51 @@ using namespace Opie; | |||
32 | #else | 32 | #else |
33 | #include "resource.h" | 33 | #include "resource.h" |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | const int col_type = 0; | 36 | const int col_type = 0; |
37 | const int col_essid = 0; | 37 | const int col_essid = 0; |
38 | const int col_sig = 1; | 38 | const int col_sig = 1; |
39 | const int col_ap = 2; | 39 | const int col_ap = 2; |
40 | const int col_channel = 3; | 40 | const int col_channel = 3; |
41 | const int col_wep = 4; | 41 | const int col_wep = 4; |
42 | const int col_traffic = 5; | 42 | const int col_traffic = 5; |
43 | const int col_manuf = 6; | 43 | const int col_manuf = 6; |
44 | const int col_firstseen = 7; | 44 | const int col_firstseen = 7; |
45 | const int col_lastseen = 8; | 45 | const int col_lastseen = 8; |
46 | 46 | ||
47 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 47 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
48 | :OListView( parent, name ), _manufacturerdb( 0 ) | 48 | :OListView( parent, name ), _manufacturerdb( 0 ) |
49 | { | 49 | { |
50 | 50 | ||
51 | setFrameShape( QListView::StyledPanel ); | 51 | setFrameShape( QListView::StyledPanel ); |
52 | setFrameShadow( QListView::Sunken ); | 52 | setFrameShadow( QListView::Sunken ); |
53 | 53 | ||
54 | addColumn( tr( "Net/Station" ) ); | 54 | addColumn( tr( "Net/Station" ) ); |
55 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); | 55 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); |
56 | addColumn( tr( "B" ) ); | 56 | addColumn( tr( "#" ) ); |
57 | setColumnAlignment( 1, AlignCenter ); | 57 | setColumnAlignment( 1, AlignCenter ); |
58 | addColumn( tr( "AP" ) ); | 58 | addColumn( tr( "MAC" ) ); |
59 | setColumnAlignment( 2, AlignCenter ); | 59 | setColumnAlignment( 2, AlignCenter ); |
60 | addColumn( tr( "Chn" ) ); | 60 | addColumn( tr( "Chn" ) ); |
61 | setColumnAlignment( 3, AlignCenter ); | 61 | setColumnAlignment( 3, AlignCenter ); |
62 | addColumn( tr( "W" ) ); | 62 | addColumn( tr( "W" ) ); |
63 | setColumnAlignment( 4, AlignCenter ); | 63 | setColumnAlignment( 4, AlignCenter ); |
64 | addColumn( tr( "T" ) ); | 64 | addColumn( tr( "T" ) ); |
65 | setColumnAlignment( 5, AlignCenter ); | 65 | setColumnAlignment( 5, AlignCenter ); |
66 | addColumn( tr( "Manufacturer" ) ); | 66 | addColumn( tr( "Manufacturer" ) ); |
67 | setColumnAlignment( 6, AlignCenter ); | 67 | setColumnAlignment( 6, AlignCenter ); |
68 | addColumn( tr( "First Seen" ) ); | 68 | addColumn( tr( "First Seen" ) ); |
69 | setColumnAlignment( 7, AlignCenter ); | 69 | setColumnAlignment( 7, AlignCenter ); |
70 | addColumn( tr( "Last Seen" ) ); | 70 | addColumn( tr( "Last Seen" ) ); |
71 | setColumnAlignment( 8, AlignCenter ); | 71 | setColumnAlignment( 8, AlignCenter ); |
72 | setRootIsDecorated( true ); | 72 | setRootIsDecorated( true ); |
73 | setAllColumnsShowFocus( true ); | 73 | setAllColumnsShowFocus( true ); |
74 | }; | 74 | }; |
75 | 75 | ||
76 | MScanListView::~MScanListView() | 76 | MScanListView::~MScanListView() |
77 | { | 77 | { |
78 | }; | 78 | }; |
79 | 79 | ||
80 | OListViewItem* MScanListView::childFactory() | 80 | OListViewItem* MScanListView::childFactory() |
81 | { | 81 | { |
82 | return new MScanListItem( this ); | 82 | return new MScanListItem( this ); |
@@ -127,98 +127,110 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
127 | network = item; | 127 | network = item; |
128 | 128 | ||
129 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 129 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
130 | assert( item ); // this shouldn't fail | 130 | assert( item ); // this shouldn't fail |
131 | 131 | ||
132 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 132 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
133 | { | 133 | { |
134 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 134 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
135 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 135 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
136 | } | 136 | } |
137 | 137 | ||
138 | if ( item ) | 138 | if ( item ) |
139 | { | 139 | { |
140 | // we have already seen this item, it's a dupe | 140 | // we have already seen this item, it's a dupe |
141 | #ifdef DEBUG | 141 | #ifdef DEBUG |
142 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 142 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
143 | #endif | 143 | #endif |
144 | item->receivedBeacon(); | 144 | item->receivedBeacon(); |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | 150 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); |
151 | //TODO send s to logwindow | ||
151 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 152 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
152 | } | 153 | } |
153 | 154 | ||
154 | 155 | ||
155 | // insert new station as child from network | 156 | // insert new station as child from network |
156 | |||
157 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 157 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
158 | 158 | ||
159 | qDebug( "inserting new station %s", (const char*) macaddr ); | 159 | qDebug( "inserting new station %s", (const char*) macaddr ); |
160 | 160 | ||
161 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 161 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
162 | if ( _manufacturerdb ) | 162 | if ( _manufacturerdb ) |
163 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); | 163 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); |
164 | 164 | ||
165 | if ( type == "managed" ) | 165 | if ( type == "managed" ) |
166 | { | 166 | { |
167 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | 167 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); |
168 | } | 168 | } |
169 | else | 169 | else |
170 | { | 170 | { |
171 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | 171 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); |
172 | } | 172 | } |
173 | //TODO send s to logwindow | ||
173 | 174 | ||
174 | } | 175 | } |
175 | 176 | ||
176 | 177 | ||
177 | void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) | 178 | void MScanListView::addIfNotExisting( MScanListItem* network, QString addr, const QString& type ) |
178 | { | 179 | { |
179 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 180 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
180 | 181 | ||
181 | while ( subitem && ( subitem->text( col_ap ) != addr ) ) | 182 | while ( subitem && ( subitem->text( col_ap ) != addr ) ) |
182 | { | 183 | { |
183 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 184 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
184 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 185 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
185 | } | 186 | } |
186 | 187 | ||
187 | if ( subitem ) | 188 | if ( subitem ) |
188 | { | 189 | { |
189 | // we have already seen this item, it's a dupe | 190 | // we have already seen this item, it's a dupe |
190 | #ifdef DEBUG | 191 | #ifdef DEBUG |
191 | qDebug( "%s is a dupe - ignoring...", (const char*) addr ); | 192 | qDebug( "%s is a dupe - ignoring...", (const char*) addr ); |
192 | #endif | 193 | #endif |
193 | subitem->receivedBeacon(); //FIXME: sent data bit | 194 | subitem->receivedBeacon(); //FIXME: sent data bit |
194 | return; | 195 | return; |
195 | } | 196 | } |
196 | 197 | ||
197 | // Hey, it seems to be a new item :-D | 198 | // Hey, it seems to be a new item :-D |
198 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr, false, -1, -1 ); | 199 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr, false, -1, -1 ); |
199 | if ( _manufacturerdb ) | 200 | if ( _manufacturerdb ) |
200 | station->setManufacturer( _manufacturerdb->lookup( addr ) ); | 201 | station->setManufacturer( _manufacturerdb->lookup( addr ) ); |
202 | |||
203 | QString s; | ||
204 | if ( type == "station" ) | ||
205 | { | ||
206 | s.sprintf( "(i) new station in '%s' [??]", (const char*) network->text( col_essid ) ); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | s.sprintf( "(i) new wireless station in '%s' [??]", (const char*) network->text( col_essid ) ); | ||
211 | } | ||
212 | //TODO send s to logwindow | ||
201 | } | 213 | } |
202 | 214 | ||
203 | 215 | ||
204 | void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) | 216 | void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo ) |
205 | { | 217 | { |
206 | QString s; | 218 | QString s; |
207 | MScanListItem* network; | 219 | MScanListItem* network; |
208 | 220 | ||
209 | QListViewItemIterator it( this ); | 221 | QListViewItemIterator it( this ); |
210 | while ( it.current() && | 222 | while ( it.current() && |
211 | it.current()->text( col_ap ) != viaFrom && | 223 | it.current()->text( col_ap ) != viaFrom && |
212 | it.current()->text( col_ap ) != viaTo ) ++it; | 224 | it.current()->text( col_ap ) != viaTo ) ++it; |
213 | 225 | ||
214 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 226 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
215 | 227 | ||
216 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 228 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
217 | { | 229 | { |
218 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 230 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
219 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 231 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
220 | } | 232 | } |
221 | else | 233 | else |
222 | { | 234 | { |
223 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 235 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
224 | } | 236 | } |