summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-12-09 19:37:47 (UTC)
committer mickeyl <mickeyl>2002-12-09 19:37:47 (UTC)
commit046f040efcb0f313818d1dbb1dc1db9021678175 (patch) (unidiff)
tree7fe87d0cfecc6a61856285e307dfc592bbd55fbd
parent711d8c1af3ebdd6f88ff3e9ffa46624c9b63badd (diff)
downloadopie-046f040efcb0f313818d1dbb1dc1db9021678175.zip
opie-046f040efcb0f313818d1dbb1dc1db9021678175.tar.gz
opie-046f040efcb0f313818d1dbb1dc1db9021678175.tar.bz2
improved display logic
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/logwindow.cpp1
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.cpp6
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp81
3 files changed, 65 insertions, 23 deletions
diff --git a/noncore/net/wellenreiter/gui/logwindow.cpp b/noncore/net/wellenreiter/gui/logwindow.cpp
index dafb429..c355f09 100644
--- a/noncore/net/wellenreiter/gui/logwindow.cpp
+++ b/noncore/net/wellenreiter/gui/logwindow.cpp
@@ -32,6 +32,7 @@ void MLogWindow::log( QString text )
32 QString line; 32 QString line;
33 line.sprintf( "[%s] %s", (const char*) time.toString(), (const char*) text ); 33 line.sprintf( "[%s] %s", (const char*) time.toString(), (const char*) text );
34 ledit->append( line ); 34 ledit->append( line );
35 qDebug( line );
35 36
36}; 37};
37 38
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp
index 189a12d..398b42d 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.cpp
+++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp
@@ -44,7 +44,11 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid
44 44
45void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 45void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
46{ 46{
47 qDebug( "decorating scanlist item" ); 47 qDebug( "decorating scanlist item %s / %s / %s [%d]",
48 (const char*) type,
49 (const char*) essid,
50 (const char*) macaddr,
51 channel );
48 52
49 // set icon for managed or adhoc mode 53 // set icon for managed or adhoc mode
50 QString name; 54 QString name;
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 9c8630f..6d62fa8 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -19,6 +19,7 @@
19 19
20// Standard 20// Standard
21 21
22#include <assert.h>
22#include <unistd.h> 23#include <unistd.h>
23#include <sys/types.h> 24#include <sys/types.h>
24 25
@@ -84,12 +85,11 @@ typedef struct {
84} wl_network_t; 85} wl_network_t;
85*/ 86*/
86 87
87 qDebug( "Sniffer sent: '%s'", (const char*) &buffer ); 88 // qDebug( "Sniffer sent: '%s'", (const char*) buffer );
88 hexwindow->log( (const char*) &buffer ); 89 hexwindow->log( (const char*) &buffer );
89 90
90 if ( result == NETFOUND ) /* new network found */ 91 if ( result == NETFOUND ) /* new network found */
91 { 92 {
92 logwindow->log( "(i) found new network" );
93 qDebug( "Sniffer said: new network found." ); 93 qDebug( "Sniffer said: new network found." );
94 wl_network_t n; 94 wl_network_t n;
95 get_network_found( &n, (char*) &buffer ); 95 get_network_found( &n, (char*) &buffer );
@@ -100,12 +100,12 @@ typedef struct {
100 //n.bssid[n.ssid_len] = "\0"; 100 //n.bssid[n.ssid_len] = "\0";
101 101
102 QString type; 102 QString type;
103 103
104 if ( n.net_type == 1 ) 104 if ( n.net_type == 1 )
105 type = "managed"; 105 type = "managed";
106 else 106 else
107 type = "adhoc"; 107 type = "adhoc";
108 108
109 addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); 109 addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 );
110 110
111 } 111 }
@@ -138,7 +138,10 @@ void Wellenreiter::timerEvent( QTimerEvent* e )
138{ 138{
139 qDebug( "checking for message..." ); 139 qDebug( "checking for message..." );
140 140
141 if ( hasMessage() ) 141 int result = hasMessage();
142 qDebug( "hasMessage() returned %d", result );
143
144 if ( result )
142 { 145 {
143 handleMessage(); 146 handleMessage();
144 } 147 }
@@ -151,41 +154,75 @@ void Wellenreiter::timerEvent( QTimerEvent* e )
151void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 154void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
152{ 155{
153 // FIXME: this code belongs in customized QListView, not into this class 156 // FIXME: this code belongs in customized QListView, not into this class
157 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
154 158
155 // search, if we had an item with this essid once before 159 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]",
156 160 (const char*) type,
157 //MScanListItem* item = dynamic_cast<MScanListItem*>( netview->firstChild() ); 161 (const char*) essid,
158 MScanListItem* item = static_cast<MScanListItem*>( netview->firstChild() ); 162 (const char*) macaddr,
163 channel );
164
165 // search, if we already have seen this net
166
167 QString s;
168 MScanListItem* network;
169 MScanListItem* item = (MScanListItem*) netview->firstChild();
159 170
160 while ( item && ( item->text( 0 ) != essid ) ) 171 while ( item && ( item->text( 0 ) != essid ) )
161 { 172 {
162 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 173 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
163 item = dynamic_cast<MScanListItem*>( item->itemBelow() ); 174 item = item->itemBelow();
164 } 175 }
165 if ( item ) 176 if ( item )
166 { 177 {
167 qDebug( "found!" ); 178 // we have already seen this net, check all childs if MAC exists
168 179
169 // check, if it is the same item (based on MACaddr) 180 network = item;
170 181
171 if ( macaddr == item->text( 2 ) ) 182 item = item->firstChild();
183 assert( item ); // this shouldn't fail
184
185 while ( item && ( item->text( 2 ) != macaddr ) )
172 { 186 {
173 qDebug( "already had item with mac %s", (const char*) item->text( 2 ) ); 187 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
174 return; 188 item = item->itemBelow();
175 } 189 }
176
177 // another item belonging to the same net, so: insert the new item as child
178 190
179 new MScanListItem( item, type, essid, macaddr, wep, channel, signal ); 191 if ( item )
192 {
193 // we have already seen this item, it's a dupe
194 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
195 return;
196 }
180 } 197 }
181
182 else 198 else
183 { 199 {
184 qDebug( "inserting new network" ); 200 s.sprintf( "(i) new network: '%s'", (const char*) essid );
185 MScanListItem* network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); 201 logwindow->log( s );
202
203 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 );
204 }
205
206
207 // insert new station as child from network
208
209 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
210
211 qDebug( "inserting new station %s", (const char*) macaddr );
186 212
187 new MScanListItem( network, type, essid, macaddr, wep, channel, signal ); 213 new MScanListItem( network, type, "", macaddr, wep, channel, signal );
214
215 if ( type == "managed" )
216 {
217 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
218 }
219 else
220 {
221 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
188 } 222 }
223
224 logwindow->log( s );
225
189} 226}
190 227
191void Wellenreiter::buttonClicked() 228void Wellenreiter::buttonClicked()