Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index f907afc..6d032aa 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -16,2 +16,102 @@ | |||
16 | #include "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "scanlistitem.h" | ||
18 | |||
19 | #include <assert.h> | ||
20 | |||
21 | MScanListView::MScanListView( QWidget* parent, const char* name ) | ||
22 | :QListView( parent, name ) | ||
23 | { | ||
24 | }; | ||
25 | |||
26 | MScanListView::~MScanListView() | ||
27 | { | ||
28 | }; | ||
29 | |||
30 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | ||
31 | { | ||
32 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | ||
33 | |||
34 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", | ||
35 | (const char*) type, | ||
36 | (const char*) essid, | ||
37 | (const char*) macaddr, | ||
38 | channel ); | ||
39 | |||
40 | // search, if we already have seen this net | ||
41 | |||
42 | QString s; | ||
43 | MScanListItem* network; | ||
44 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | ||
45 | |||
46 | while ( item && ( item->text( 0 ) != essid ) ) | ||
47 | { | ||
48 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | ||
49 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
50 | } | ||
51 | if ( item ) | ||
52 | { | ||
53 | // animate the item | ||
54 | |||
55 | /* | ||
56 | |||
57 | const QPixmap* pixmap = item->pixmap( 0 ); | ||
58 | const QPixmap* nextpixmap = ani2; | ||
59 | if ( pixmap == ani1 ) | ||
60 | nextpixmap = ani2; | ||
61 | else if ( pixmap == ani2 ) | ||
62 | nextpixmap = ani3; | ||
63 | else if ( pixmap == ani3 ) | ||
64 | nextpixmap = ani4; | ||
65 | else if ( pixmap == ani4 ) | ||
66 | nextpixmap = ani1; | ||
67 | item->setPixmap( 0, *nextpixmap ); */ | ||
68 | |||
69 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | ||
70 | |||
71 | // we have already seen this net, check all childs if MAC exists | ||
72 | |||
73 | network = item; | ||
74 | |||
75 | item = static_cast<MScanListItem*> ( item->firstChild() ); | ||
76 | assert( item ); // this shouldn't fail | ||
77 | |||
78 | while ( item && ( item->text( 2 ) != macaddr ) ) | ||
79 | { | ||
80 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | ||
81 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
82 | } | ||
83 | |||
84 | if ( item ) | ||
85 | { | ||
86 | // we have already seen this item, it's a dupe | ||
87 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | ||
88 | return; | ||
89 | } | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | ||
94 | |||
95 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); | ||
96 | } | ||
97 | |||
98 | |||
99 | // insert new station as child from network | ||
100 | |||
101 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | ||
102 | |||
103 | qDebug( "inserting new station %s", (const char*) macaddr ); | ||
104 | |||
105 | new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | ||
106 | |||
107 | if ( type == "managed" ) | ||
108 | { | ||
109 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | ||
114 | } | ||
115 | |||
116 | } | ||
17 | 117 | ||