author | mickeyl <mickeyl> | 2003-02-24 21:37:49 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-02-24 21:37:49 (UTC) |
commit | d14b92ef8984ae654ff187bf6c8f5946d3ba218d (patch) (unidiff) | |
tree | fd209280150b48eb137315d9bfe693892525697e | |
parent | 93151a1467b45759d320ce6673160190d6ab8872 (diff) | |
download | opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.zip opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.tar.gz opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.tar.bz2 |
- work around yet another g++ 2.x bug
- started work on saving session to xml
[ any classes from libopie I can reuse without too much effort? ]
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 60 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 32 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 1 |
9 files changed, 118 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp index bca17b2..8bc59de 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp | |||
@@ -77,186 +77,186 @@ int OListView::addColumn( const QString& label, int width ) | |||
77 | #endif | 77 | #endif |
78 | return result; | 78 | return result; |
79 | } | 79 | } |
80 | 80 | ||
81 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 81 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
82 | { | 82 | { |
83 | int result = QListView::addColumn( iconset, label, width ); | 83 | int result = QListView::addColumn( iconset, label, width ); |
84 | #if QT_VERSION > 290 | 84 | #if QT_VERSION > 290 |
85 | if (m_fullWidth) { | 85 | if (m_fullWidth) { |
86 | header()->setStretchEnabled( false, columns()-2 ); | 86 | header()->setStretchEnabled( false, columns()-2 ); |
87 | header()->setStretchEnabled( true, columns()-1 ); | 87 | header()->setStretchEnabled( true, columns()-1 ); |
88 | } | 88 | } |
89 | #endif | 89 | #endif |
90 | return result; | 90 | return result; |
91 | } | 91 | } |
92 | 92 | ||
93 | void OListView::removeColumn( int index ) | 93 | void OListView::removeColumn( int index ) |
94 | { | 94 | { |
95 | QListView::removeColumn(index); | 95 | QListView::removeColumn(index); |
96 | #if QT_VERSION > 290 | 96 | #if QT_VERSION > 290 |
97 | if ( m_fullWidth && index == columns() ) | 97 | if ( m_fullWidth && index == columns() ) |
98 | { | 98 | { |
99 | header()->setStretchEnabled( true, columns()-1 ); | 99 | header()->setStretchEnabled( true, columns()-1 ); |
100 | } | 100 | } |
101 | #endif | 101 | #endif |
102 | } | 102 | } |
103 | 103 | ||
104 | const QColor& OListView::alternateBackground() const | 104 | const QColor& OListView::alternateBackground() const |
105 | { | 105 | { |
106 | return m_alternateBackground; | 106 | return m_alternateBackground; |
107 | } | 107 | } |
108 | 108 | ||
109 | void OListView::setAlternateBackground( const QColor &c ) | 109 | void OListView::setAlternateBackground( const QColor &c ) |
110 | { | 110 | { |
111 | m_alternateBackground = c; | 111 | m_alternateBackground = c; |
112 | repaint(); | 112 | repaint(); |
113 | } | 113 | } |
114 | 114 | ||
115 | const QPen& OListView::columnSeparator() const | 115 | const QPen& OListView::columnSeparator() const |
116 | { | 116 | { |
117 | return m_columnSeparator; | 117 | return m_columnSeparator; |
118 | } | 118 | } |
119 | 119 | ||
120 | void OListView::setColumnSeparator( const QPen& p ) | 120 | void OListView::setColumnSeparator( const QPen& p ) |
121 | { | 121 | { |
122 | m_columnSeparator = p; | 122 | m_columnSeparator = p; |
123 | repaint(); | 123 | repaint(); |
124 | } | 124 | } |
125 | 125 | ||
126 | //****************************** OListViewItem *********************************************************************** | 126 | //****************************** OListViewItem *********************************************************************** |
127 | 127 | ||
128 | OListViewItem::OListViewItem(QListView *parent) | 128 | OListViewItem::OListViewItem(QListView *parent) |
129 | : QListViewItem(parent) | 129 | : QListViewItem(parent) |
130 | { | 130 | { |
131 | init(); | 131 | init(); |
132 | } | 132 | } |
133 | 133 | ||
134 | OListViewItem::OListViewItem(QListViewItem *parent) | 134 | OListViewItem::OListViewItem(QListViewItem *parent) |
135 | : QListViewItem(parent) | 135 | : QListViewItem(parent) |
136 | { | 136 | { |
137 | init(); | 137 | init(); |
138 | } | 138 | } |
139 | 139 | ||
140 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) | 140 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) |
141 | : QListViewItem(parent, after) | 141 | : QListViewItem(parent, after) |
142 | { | 142 | { |
143 | init(); | 143 | init(); |
144 | } | 144 | } |
145 | 145 | ||
146 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) | 146 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) |
147 | : QListViewItem(parent, after) | 147 | : QListViewItem(parent, after) |
148 | { | 148 | { |
149 | init(); | 149 | init(); |
150 | } | 150 | } |
151 | 151 | ||
152 | OListViewItem::OListViewItem(QListView *parent, | 152 | OListViewItem::OListViewItem(QListView *parent, |
153 | QString label1, QString label2, QString label3, QString label4, | 153 | QString label1, QString label2, QString label3, QString label4, |
154 | QString label5, QString label6, QString label7, QString label8) | 154 | QString label5, QString label6, QString label7, QString label8) |
155 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 155 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
156 | { | 156 | { |
157 | init(); | 157 | init(); |
158 | } | 158 | } |
159 | 159 | ||
160 | OListViewItem::OListViewItem(QListViewItem *parent, | 160 | OListViewItem::OListViewItem(QListViewItem *parent, |
161 | QString label1, QString label2, QString label3, QString label4, | 161 | QString label1, QString label2, QString label3, QString label4, |
162 | QString label5, QString label6, QString label7, QString label8) | 162 | QString label5, QString label6, QString label7, QString label8) |
163 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 163 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
164 | { | 164 | { |
165 | init(); | 165 | init(); |
166 | } | 166 | } |
167 | 167 | ||
168 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, | 168 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, |
169 | QString label1, QString label2, QString label3, QString label4, | 169 | QString label1, QString label2, QString label3, QString label4, |
170 | QString label5, QString label6, QString label7, QString label8) | 170 | QString label5, QString label6, QString label7, QString label8) |
171 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 171 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
172 | { | 172 | { |
173 | init(); | 173 | init(); |
174 | } | 174 | } |
175 | 175 | ||
176 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, | 176 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, |
177 | QString label1, QString label2, QString label3, QString label4, | 177 | QString label1, QString label2, QString label3, QString label4, |
178 | QString label5, QString label6, QString label7, QString label8) | 178 | QString label5, QString label6, QString label7, QString label8) |
179 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 179 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
180 | { | 180 | { |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | OListViewItem::~OListViewItem() | 184 | OListViewItem::~OListViewItem() |
185 | { | 185 | { |
186 | } | 186 | } |
187 | 187 | ||
188 | void OListViewItem::init() | 188 | void OListViewItem::init() |
189 | { | 189 | { |
190 | m_known = false; | 190 | m_known = false; |
191 | } | 191 | } |
192 | 192 | ||
193 | const QColor &OListViewItem::backgroundColor() | 193 | const QColor &OListViewItem::backgroundColor() |
194 | { | 194 | { |
195 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | 195 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : |
196 | listView()->viewport()->colorGroup().base(); | 196 | listView()->viewport()->colorGroup().base(); |
197 | } | 197 | } |
198 | 198 | ||
199 | bool OListViewItem::isAlternate() | 199 | bool OListViewItem::isAlternate() |
200 | { | 200 | { |
201 | OListView *lv = static_cast<OListView*>( listView() ); | 201 | OListView *lv = static_cast<OListView*>( listView() ); |
202 | 202 | ||
203 | // check if the item above is an OListViewItem | 203 | // check if the item above is an OListViewItem |
204 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); | 204 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); |
205 | /*if (not itemAbove()->inherits( "OListViewItem" )) return false;*/ | 205 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ |
206 | 206 | ||
207 | // check if we have a valid alternate background color | 207 | // check if we have a valid alternate background color |
208 | if (not (lv && lv->alternateBackground().isValid())) return false; | 208 | if (!(lv && lv->alternateBackground().isValid())) return false; |
209 | 209 | ||
210 | m_known = above ? above->m_known : true; | 210 | m_known = above ? above->m_known : true; |
211 | if (m_known) | 211 | if (m_known) |
212 | { | 212 | { |
213 | m_odd = above ? !above->m_odd : false; | 213 | m_odd = above ? !above->m_odd : false; |
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | OListViewItem *item; | 217 | OListViewItem *item; |
218 | bool previous = true; | 218 | bool previous = true; |
219 | if (parent()) | 219 | if (parent()) |
220 | { | 220 | { |
221 | item = static_cast<OListViewItem *>(parent()); | 221 | item = static_cast<OListViewItem *>(parent()); |
222 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; | 222 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; |
223 | item = static_cast<OListViewItem *>(parent()->firstChild()); | 223 | item = static_cast<OListViewItem *>(parent()->firstChild()); |
224 | /* if !( item.inherits( "OListViewItem" ) item = 0; */ | 224 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ |
225 | } | 225 | } |
226 | else | 226 | else |
227 | { | 227 | { |
228 | item = static_cast<OListViewItem *>(lv->firstChild()); | 228 | item = static_cast<OListViewItem *>(lv->firstChild()); |
229 | } | 229 | } |
230 | 230 | ||
231 | while(item) | 231 | while(item) |
232 | { | 232 | { |
233 | item->m_odd = previous = !previous; | 233 | item->m_odd = previous = !previous; |
234 | item->m_known = true; | 234 | item->m_known = true; |
235 | item = static_cast<OListViewItem *>(item->nextSibling()); | 235 | item = static_cast<OListViewItem *>(item->nextSibling()); |
236 | /* if !(item.inherits( "OListViewItem" ) ) break; */ | 236 | /* if (!item.inherits( "OListViewItem" ) ) break; */ |
237 | } | 237 | } |
238 | } | 238 | } |
239 | return m_odd; | 239 | return m_odd; |
240 | } | 240 | } |
241 | 241 | ||
242 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 242 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
243 | { | 243 | { |
244 | QColorGroup _cg = cg; | 244 | QColorGroup _cg = cg; |
245 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 245 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
246 | if (pm && !pm->isNull()) | 246 | if (pm && !pm->isNull()) |
247 | { | 247 | { |
248 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 248 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
249 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 249 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
250 | } | 250 | } |
251 | else if ( isAlternate() ) | 251 | else if ( isAlternate() ) |
252 | { | 252 | { |
253 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 253 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
254 | } | 254 | } |
255 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 255 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
256 | 256 | ||
257 | //FIXME: Use styling here? | 257 | //FIXME: Use styling here? |
258 | 258 | ||
259 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 259 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
260 | p->setPen( pen ); | 260 | p->setPen( pen ); |
261 | p->drawLine( width-1, 0, width-1, height() ); | 261 | p->drawLine( width-1, 0, width-1, height() ); |
262 | } | 262 | } |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index cb003dd..e388fc5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,198 +1,240 @@ | |||
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 "configwindow.h" | 16 | #include "configwindow.h" |
17 | #include "logwindow.h" | 17 | #include "logwindow.h" |
18 | #include "mainwindow.h" | 18 | #include "mainwindow.h" |
19 | #include "wellenreiter.h" | 19 | #include "wellenreiter.h" |
20 | 20 | ||
21 | #include "scanlist.h" | 21 | #include "scanlist.h" |
22 | 22 | ||
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qmenubar.h> | 26 | #include <qmenubar.h> |
27 | #include <qmessagebox.h> | ||
27 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
28 | #include <qstatusbar.h> | 29 | #include <qstatusbar.h> |
29 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
30 | #include <qtoolbutton.h> | 31 | #include <qtoolbutton.h> |
31 | 32 | ||
32 | #ifdef QWS | 33 | #ifdef QWS |
33 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
34 | #else | 35 | #else |
35 | #include "resource.h" | 36 | #include "resource.h" |
36 | #endif | 37 | #endif |
37 | 38 | ||
38 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 39 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
39 | :QMainWindow( parent, name, f ) | 40 | :QMainWindow( parent, name, f ) |
40 | { | 41 | { |
41 | cw = new WellenreiterConfigWindow( this ); | 42 | cw = new WellenreiterConfigWindow( this ); |
42 | mw = new Wellenreiter( this ); | 43 | mw = new Wellenreiter( this ); |
43 | mw->setConfigWindow( cw ); | 44 | mw->setConfigWindow( cw ); |
44 | setCentralWidget( mw ); | 45 | setCentralWidget( mw ); |
45 | 46 | ||
46 | // setup icon sets | 47 | // setup icon sets |
47 | 48 | ||
48 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); | 49 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); |
49 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); | 50 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); |
50 | #ifdef QWS | 51 | #ifdef QWS |
51 | searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); | 52 | searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); |
52 | cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); | 53 | cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); |
53 | #else | 54 | #else |
54 | startStopIconSet = new QIconSet(); | 55 | startStopIconSet = new QIconSet(); |
55 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); | 56 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); |
56 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); | 57 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | // setup tool buttons | 60 | // setup tool buttons |
60 | 61 | ||
61 | startStopButton = new QToolButton( 0 ); | 62 | startStopButton = new QToolButton( 0 ); |
63 | #ifdef QWS | ||
62 | startStopButton->setAutoRaise( true ); | 64 | startStopButton->setAutoRaise( true ); |
65 | #endif | ||
63 | #ifdef QWS | 66 | #ifdef QWS |
64 | startStopButton->setOnIconSet( *cancelIconSet ); | 67 | startStopButton->setOnIconSet( *cancelIconSet ); |
65 | startStopButton->setOffIconSet( *searchIconSet ); | 68 | startStopButton->setOffIconSet( *searchIconSet ); |
66 | #else | 69 | #else |
67 | startStopButton->setIconSet( *startStopIconSet ); | 70 | startStopButton->setIconSet( *startStopIconSet ); |
68 | #endif | 71 | #endif |
69 | startStopButton->setToggleButton( true ); | 72 | startStopButton->setToggleButton( true ); |
70 | connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); | 73 | connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); |
71 | startStopButton->setEnabled( false ); | 74 | startStopButton->setEnabled( false ); |
72 | 75 | ||
73 | QToolButton* c = new QToolButton( 0 ); | 76 | QToolButton* c = new QToolButton( 0 ); |
77 | #ifdef QWS | ||
74 | c->setAutoRaise( true ); | 78 | c->setAutoRaise( true ); |
79 | #endif | ||
75 | c->setIconSet( *infoIconSet ); | 80 | c->setIconSet( *infoIconSet ); |
76 | c->setEnabled( false ); | 81 | c->setEnabled( false ); |
77 | 82 | ||
78 | QToolButton* d = new QToolButton( 0 ); | 83 | QToolButton* d = new QToolButton( 0 ); |
84 | #ifdef QWS | ||
79 | d->setAutoRaise( true ); | 85 | d->setAutoRaise( true ); |
86 | #endif | ||
80 | d->setIconSet( *settingsIconSet ); | 87 | d->setIconSet( *settingsIconSet ); |
81 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 88 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
82 | 89 | ||
83 | // setup menu bar | 90 | // setup menu bar |
84 | 91 | ||
85 | int id; | 92 | int id; |
86 | 93 | ||
87 | QMenuBar* mb = menuBar(); | 94 | QMenuBar* mb = menuBar(); |
88 | 95 | ||
89 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 96 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
97 | fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) ); | ||
90 | fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) ); | 98 | fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) ); |
91 | 99 | ||
100 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | ||
101 | fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); | ||
102 | fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | ||
103 | |||
92 | QPopupMenu* file = new QPopupMenu( mb ); | 104 | QPopupMenu* file = new QPopupMenu( mb ); |
93 | id = file->insertItem( "&Load" ); | 105 | id = file->insertItem( "&Load", fileLoad ); |
94 | file->setItemEnabled( id, false ); | 106 | file->setItemEnabled( id, false ); |
95 | file->insertItem( "&Save", fileSave ); | 107 | file->insertItem( "&Save", fileSave ); |
96 | 108 | ||
97 | QPopupMenu* view = new QPopupMenu( mb ); | 109 | QPopupMenu* view = new QPopupMenu( mb ); |
98 | view->insertItem( "&Configure..." ); | 110 | view->insertItem( "&Configure..." ); |
99 | 111 | ||
100 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 112 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
101 | sniffer->insertItem( "&Configure..." ); | 113 | sniffer->insertItem( "&Configure..." ); |
102 | sniffer->insertSeparator(); | 114 | sniffer->insertSeparator(); |
103 | 115 | ||
104 | QPopupMenu* demo = new QPopupMenu( mb ); | 116 | QPopupMenu* demo = new QPopupMenu( mb ); |
105 | demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); | 117 | demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); |
106 | 118 | ||
107 | id = mb->insertItem( "&File", file ); | 119 | id = mb->insertItem( "&File", file ); |
108 | id = mb->insertItem( "&View", view ); | 120 | id = mb->insertItem( "&View", view ); |
109 | mb->setItemEnabled( id, false ); | 121 | mb->setItemEnabled( id, false ); |
110 | id = mb->insertItem( "&Sniffer", sniffer ); | 122 | id = mb->insertItem( "&Sniffer", sniffer ); |
111 | mb->setItemEnabled( id, false ); | 123 | mb->setItemEnabled( id, false ); |
112 | id = mb->insertItem( "&Demo", demo ); | 124 | id = mb->insertItem( "&Demo", demo ); |
113 | mb->setItemEnabled( id, true ); | 125 | mb->setItemEnabled( id, true ); |
114 | 126 | ||
115 | #ifdef QWS | 127 | #ifdef QWS |
116 | mb->insertItem( startStopButton ); | 128 | mb->insertItem( startStopButton ); |
117 | mb->insertItem( c ); | 129 | mb->insertItem( c ); |
118 | mb->insertItem( d ); | 130 | mb->insertItem( d ); |
119 | #else // Qt3 changed the insertion order. It's now totally random :( | 131 | #else // Qt3 changed the insertion order. It's now totally random :( |
120 | mb->insertItem( d ); | 132 | mb->insertItem( d ); |
121 | mb->insertItem( c ); | 133 | mb->insertItem( c ); |
122 | mb->insertItem( startStopButton ); | 134 | mb->insertItem( startStopButton ); |
123 | #endif | 135 | #endif |
124 | 136 | ||
125 | // setup status bar (for now only on X11) | 137 | // setup status bar (for now only on X11) |
126 | 138 | ||
127 | #ifndef QWS | 139 | #ifndef QWS |
128 | statusBar()->message( "Ready." ); | 140 | statusBar()->message( "Ready." ); |
129 | #endif | 141 | #endif |
130 | 142 | ||
131 | }; | 143 | }; |
132 | 144 | ||
133 | void WellenreiterMainWindow::showConfigure() | 145 | void WellenreiterMainWindow::showConfigure() |
134 | { | 146 | { |
135 | qDebug( "show configure..." ); | 147 | qDebug( "show configure..." ); |
136 | cw->setCaption( tr( "Configure" ) ); | 148 | cw->setCaption( tr( "Configure" ) ); |
137 | #ifdef QWS | 149 | #ifdef QWS |
138 | cw->showMaximized(); | 150 | cw->showMaximized(); |
139 | #endif | 151 | #endif |
140 | int result = cw->exec(); | 152 | int result = cw->exec(); |
141 | 153 | ||
142 | if ( result ) | 154 | if ( result ) |
143 | { | 155 | { |
144 | // check configuration from config window | 156 | // check configuration from config window |
145 | 157 | ||
146 | const QString& interface = cw->interfaceName->currentText(); | 158 | const QString& interface = cw->interfaceName->currentText(); |
147 | const int cardtype = cw->daemonDeviceType(); | 159 | const int cardtype = cw->daemonDeviceType(); |
148 | const int interval = cw->daemonHopInterval(); | 160 | const int interval = cw->daemonHopInterval(); |
149 | 161 | ||
150 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 162 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
151 | startStopButton->setEnabled( true ); | 163 | startStopButton->setEnabled( true ); |
152 | //TODO ... | 164 | //TODO ... |
153 | else | 165 | else |
154 | startStopButton->setEnabled( false ); | 166 | startStopButton->setEnabled( false ); |
155 | //TODO ... | 167 | //TODO ... |
156 | } | 168 | } |
157 | } | 169 | } |
158 | 170 | ||
159 | WellenreiterMainWindow::~WellenreiterMainWindow() | 171 | WellenreiterMainWindow::~WellenreiterMainWindow() |
160 | { | 172 | { |
161 | 173 | ||
162 | delete infoIconSet; | 174 | delete infoIconSet; |
163 | delete settingsIconSet; | 175 | delete settingsIconSet; |
164 | #ifdef QWS | 176 | #ifdef QWS |
165 | delete searchIconSet; | 177 | delete searchIconSet; |
166 | delete cancelIconSet; | 178 | delete cancelIconSet; |
167 | #else | 179 | #else |
168 | delete startStopIconSet; | 180 | delete startStopIconSet; |
169 | #endif | 181 | #endif |
170 | 182 | ||
171 | }; | 183 | }; |
172 | 184 | ||
173 | void WellenreiterMainWindow::demoAddStations() | 185 | void WellenreiterMainWindow::demoAddStations() |
174 | { | 186 | { |
175 | mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | 187 | mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); |
176 | mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | 188 | mw->netView()->addNewItem( "managed", "Vanille", "00:00:1c:EF:A6:23", true, 11, 10 ); |
177 | mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); | 189 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); |
178 | mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); | 190 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); |
179 | mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); | 191 | mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); |
180 | } | 192 | } |
181 | 193 | ||
182 | void WellenreiterMainWindow::fileSaveLog() | 194 | void WellenreiterMainWindow::fileSaveLog() |
183 | { | 195 | { |
184 | const QString fname( "/tmp/log.txt" ); | 196 | const QString fname( "/tmp/log.txt" ); |
185 | QFile f( fname ); | 197 | QFile f( fname ); |
186 | if ( f.open(IO_WriteOnly) ) | 198 | if ( f.open(IO_WriteOnly) ) |
187 | { | 199 | { |
188 | QTextStream t( &f ); | 200 | QTextStream t( &f ); |
189 | t << mw->logWindow()->getLog(); | 201 | t << mw->logWindow()->getLog(); |
190 | f.close(); | 202 | f.close(); |
191 | qDebug( "saved log in file '%s'", (const char*) fname ); | 203 | qDebug( "Saved log to file '%s'", (const char*) fname ); |
204 | } | ||
205 | else | ||
206 | { | ||
207 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | ||
208 | } | ||
209 | |||
210 | } | ||
211 | |||
212 | void WellenreiterMainWindow::fileSaveSession() | ||
213 | { | ||
214 | const QString fname( "/tmp/session.xml" ); | ||
215 | QFile f( fname ); | ||
216 | if ( f.open(IO_WriteOnly) ) | ||
217 | { | ||
218 | QTextStream t( &f ); | ||
219 | mw->netView()->dump( t ); | ||
220 | f.close(); | ||
221 | qDebug( "Saved session to file '%s'", (const char*) fname ); | ||
192 | } | 222 | } |
193 | else | 223 | else |
194 | { | 224 | { |
195 | qDebug( "Problem saving log in file '%s'", (const char*) fname ); | 225 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); |
196 | } | 226 | } |
227 | } | ||
197 | 228 | ||
198 | } \ No newline at end of file | 229 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
230 | { | ||
231 | if ( mw->isDaemonRunning() ) | ||
232 | { | ||
233 | QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." ); | ||
234 | e->ignore(); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | QMainWindow::closeEvent( e ); | ||
239 | } | ||
240 | } | ||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 03aa08a..8bfccf3 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h | |||
@@ -1,52 +1,56 @@ | |||
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 | #ifndef MAINWINDOW_H | 16 | #ifndef MAINWINDOW_H |
17 | #define MAINWINDOW_H | 17 | #define MAINWINDOW_H |
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | 20 | ||
21 | class Wellenreiter; | 21 | class Wellenreiter; |
22 | class WellenreiterConfigWindow; | 22 | class WellenreiterConfigWindow; |
23 | class QIconSet; | 23 | class QIconSet; |
24 | class QToolButton; | 24 | class QToolButton; |
25 | 25 | ||
26 | class WellenreiterMainWindow: public QMainWindow | 26 | class WellenreiterMainWindow: public QMainWindow |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); | 31 | WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); |
32 | ~WellenreiterMainWindow(); | 32 | ~WellenreiterMainWindow(); |
33 | 33 | ||
34 | protected: | 34 | protected: |
35 | Wellenreiter* mw; | 35 | Wellenreiter* mw; |
36 | WellenreiterConfigWindow* cw; | 36 | WellenreiterConfigWindow* cw; |
37 | 37 | ||
38 | QIconSet* startStopIconSet; | 38 | QIconSet* startStopIconSet; |
39 | const QIconSet* searchIconSet; | 39 | const QIconSet* searchIconSet; |
40 | const QIconSet* infoIconSet; | 40 | const QIconSet* infoIconSet; |
41 | const QIconSet* settingsIconSet; | 41 | const QIconSet* settingsIconSet; |
42 | const QIconSet* cancelIconSet; | 42 | const QIconSet* cancelIconSet; |
43 | 43 | ||
44 | QToolButton* startStopButton; | 44 | QToolButton* startStopButton; |
45 | 45 | ||
46 | protected: | ||
47 | virtual void closeEvent( QCloseEvent* ); | ||
48 | |||
46 | public slots: | 49 | public slots: |
47 | void showConfigure(); | 50 | void showConfigure(); |
48 | void demoAddStations(); | 51 | void demoAddStations(); |
49 | void fileSaveLog(); | 52 | void fileSaveLog(); |
53 | void fileSaveSession(); | ||
50 | }; | 54 | }; |
51 | 55 | ||
52 | #endif | 56 | #endif |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 6d3469c..cdc2c48 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,153 +1,167 @@ | |||
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 "scanlistitem.h" | 17 | #include "scanlistitem.h" |
18 | 18 | ||
19 | #include <assert.h> | 19 | #include <assert.h> |
20 | 20 | ||
21 | #include "manufacturers.h" | 21 | #include "manufacturers.h" |
22 | 22 | ||
23 | #include <qtextstream.h> | ||
24 | |||
23 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 25 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
24 | :OListView( parent, name ), _manufacturerdb( 0 ) | 26 | :OListView( parent, name ), _manufacturerdb( 0 ) |
25 | { | 27 | { |
26 | 28 | ||
27 | setFrameShape( QListView::StyledPanel ); | 29 | setFrameShape( QListView::StyledPanel ); |
28 | setFrameShadow( QListView::Sunken ); | 30 | setFrameShadow( QListView::Sunken ); |
29 | 31 | ||
30 | addColumn( tr( "Net/Station" ) ); | 32 | addColumn( tr( "Net/Station" ) ); |
31 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); | 33 | setColumnAlignment( 0, AlignLeft || AlignVCenter ); |
32 | addColumn( tr( "B" ) ); | 34 | addColumn( tr( "B" ) ); |
33 | setColumnAlignment( 1, AlignCenter ); | 35 | setColumnAlignment( 1, AlignCenter ); |
34 | addColumn( tr( "AP" ) ); | 36 | addColumn( tr( "AP" ) ); |
35 | setColumnAlignment( 2, AlignCenter ); | 37 | setColumnAlignment( 2, AlignCenter ); |
36 | addColumn( tr( "Chn" ) ); | 38 | addColumn( tr( "Chn" ) ); |
37 | setColumnAlignment( 3, AlignCenter ); | 39 | setColumnAlignment( 3, AlignCenter ); |
38 | addColumn( tr( "W" ) ); | 40 | addColumn( tr( "W" ) ); |
39 | setColumnAlignment( 4, AlignCenter ); | 41 | setColumnAlignment( 4, AlignCenter ); |
40 | addColumn( tr( "T" ) ); | 42 | addColumn( tr( "T" ) ); |
41 | setColumnAlignment( 5, AlignCenter ); | 43 | setColumnAlignment( 5, AlignCenter ); |
42 | addColumn( tr( "Manufacturer" ) ); | 44 | addColumn( tr( "Manufacturer" ) ); |
43 | setColumnAlignment( 6, AlignCenter ); | 45 | setColumnAlignment( 6, AlignCenter ); |
44 | addColumn( tr( "First Seen" ) ); | 46 | addColumn( tr( "First Seen" ) ); |
45 | setColumnAlignment( 7, AlignCenter ); | 47 | setColumnAlignment( 7, AlignCenter ); |
46 | addColumn( tr( "Last Seen" ) ); | 48 | addColumn( tr( "Last Seen" ) ); |
47 | setColumnAlignment( 8, AlignCenter ); | 49 | setColumnAlignment( 8, AlignCenter ); |
48 | setRootIsDecorated( true ); | 50 | setRootIsDecorated( true ); |
49 | setAllColumnsShowFocus( true ); | 51 | setAllColumnsShowFocus( true ); |
50 | }; | 52 | }; |
51 | 53 | ||
52 | MScanListView::~MScanListView() | 54 | MScanListView::~MScanListView() |
53 | { | 55 | { |
54 | }; | 56 | }; |
55 | 57 | ||
56 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) | 58 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) |
57 | { | 59 | { |
58 | _manufacturerdb = manufacturerdb; | 60 | _manufacturerdb = manufacturerdb; |
59 | } | 61 | } |
60 | 62 | ||
61 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 63 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
62 | { | 64 | { |
63 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | 65 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) |
64 | 66 | ||
65 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", | 67 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", |
66 | (const char*) type, | 68 | (const char*) type, |
67 | (const char*) essid, | 69 | (const char*) essid, |
68 | (const char*) macaddr, | 70 | (const char*) macaddr, |
69 | channel ); | 71 | channel ); |
70 | 72 | ||
71 | // search, if we already have seen this net | 73 | // search, if we already have seen this net |
72 | 74 | ||
73 | QString s; | 75 | QString s; |
74 | MScanListItem* network; | 76 | MScanListItem* network; |
75 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 77 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
76 | 78 | ||
77 | while ( item && ( item->text( 0 ) != essid ) ) | 79 | while ( item && ( item->text( 0 ) != essid ) ) |
78 | { | 80 | { |
79 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | 81 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); |
80 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 82 | item = static_cast<MScanListItem*> ( item->itemBelow() ); |
81 | } | 83 | } |
82 | if ( item ) | 84 | if ( item ) |
83 | { | 85 | { |
84 | // animate the item | 86 | // animate the item |
85 | 87 | ||
86 | /* | 88 | /* |
87 | 89 | ||
88 | const QPixmap* pixmap = item->pixmap( 0 ); | 90 | const QPixmap* pixmap = item->pixmap( 0 ); |
89 | const QPixmap* nextpixmap = ani2; | 91 | const QPixmap* nextpixmap = ani2; |
90 | if ( pixmap == ani1 ) | 92 | if ( pixmap == ani1 ) |
91 | nextpixmap = ani2; | 93 | nextpixmap = ani2; |
92 | else if ( pixmap == ani2 ) | 94 | else if ( pixmap == ani2 ) |
93 | nextpixmap = ani3; | 95 | nextpixmap = ani3; |
94 | else if ( pixmap == ani3 ) | 96 | else if ( pixmap == ani3 ) |
95 | nextpixmap = ani4; | 97 | nextpixmap = ani4; |
96 | else if ( pixmap == ani4 ) | 98 | else if ( pixmap == ani4 ) |
97 | nextpixmap = ani1; | 99 | nextpixmap = ani1; |
98 | item->setPixmap( 0, *nextpixmap ); */ | 100 | item->setPixmap( 0, *nextpixmap ); */ |
99 | 101 | ||
100 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | 102 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); |
101 | 103 | ||
102 | // we have already seen this net, check all childs if MAC exists | 104 | // we have already seen this net, check all childs if MAC exists |
103 | 105 | ||
104 | network = item; | 106 | network = item; |
105 | 107 | ||
106 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 108 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
107 | assert( item ); // this shouldn't fail | 109 | assert( item ); // this shouldn't fail |
108 | 110 | ||
109 | while ( item && ( item->text( 2 ) != macaddr ) ) | 111 | while ( item && ( item->text( 2 ) != macaddr ) ) |
110 | { | 112 | { |
111 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | 113 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); |
112 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | 114 | item = static_cast<MScanListItem*> ( item->itemBelow() ); |
113 | } | 115 | } |
114 | 116 | ||
115 | if ( item ) | 117 | if ( item ) |
116 | { | 118 | { |
117 | // we have already seen this item, it's a dupe | 119 | // we have already seen this item, it's a dupe |
118 | #ifdef DEBUG | 120 | #ifdef DEBUG |
119 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 121 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
120 | #endif | 122 | #endif |
121 | item->receivedBeacon(); | 123 | item->receivedBeacon(); |
122 | return; | 124 | return; |
123 | } | 125 | } |
124 | } | 126 | } |
125 | else | 127 | else |
126 | { | 128 | { |
127 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | 129 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); |
128 | 130 | ||
129 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); | 131 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); |
130 | } | 132 | } |
131 | 133 | ||
132 | 134 | ||
133 | // insert new station as child from network | 135 | // insert new station as child from network |
134 | 136 | ||
135 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 137 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
136 | 138 | ||
137 | qDebug( "inserting new station %s", (const char*) macaddr ); | 139 | qDebug( "inserting new station %s", (const char*) macaddr ); |
138 | 140 | ||
139 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 141 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
140 | if ( _manufacturerdb ) | 142 | if ( _manufacturerdb ) |
141 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); | 143 | station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); |
142 | 144 | ||
143 | if ( type == "managed" ) | 145 | if ( type == "managed" ) |
144 | { | 146 | { |
145 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | 147 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); |
146 | } | 148 | } |
147 | else | 149 | else |
148 | { | 150 | { |
149 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | 151 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); |
150 | } | 152 | } |
151 | 153 | ||
152 | } | 154 | } |
153 | 155 | ||
156 | void MScanListView::dump( QTextStream& t ) const | ||
157 | { | ||
158 | qDebug( "dumping scanlist..." ); | ||
159 | |||
160 | QListViewItemIterator it( const_cast<MScanListView*>( this ) ); | ||
161 | for ( ; it.current(); ++it ) | ||
162 | { | ||
163 | static_cast<MScanListItem*>( it.current() )->dump( t ); | ||
164 | } | ||
165 | |||
166 | qDebug( "dump finished." ); | ||
167 | } | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 475f7b6..f06f251 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -1,44 +1,46 @@ | |||
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 | #ifndef SCANLIST_H | 16 | #ifndef SCANLIST_H |
17 | #define SCANLIST_H | 17 | #define SCANLIST_H |
18 | 18 | ||
19 | #include <cornucopia/olistview.h> | 19 | #include <cornucopia/olistview.h> |
20 | 20 | ||
21 | class QString; | 21 | #include <qtextstream.h> |
22 | 22 | ||
23 | class QString; | ||
23 | class ManufacturerDB; | 24 | class ManufacturerDB; |
24 | 25 | ||
25 | class MScanListView: public OListView | 26 | class MScanListView: public OListView |
26 | { | 27 | { |
27 | Q_OBJECT | 28 | Q_OBJECT |
28 | 29 | ||
29 | public: | 30 | public: |
30 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | 31 | MScanListView( QWidget* parent = 0, const char* name = 0 ); |
31 | virtual ~MScanListView(); | 32 | virtual ~MScanListView(); |
32 | 33 | ||
33 | void setManufacturerDB( ManufacturerDB* manufacturerdb ); | 34 | void setManufacturerDB( ManufacturerDB* manufacturerdb ); |
34 | 35 | void dump( QTextStream& t ) const; | |
36 | |||
35 | public slots: | 37 | public slots: |
36 | void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 38 | void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); |
37 | 39 | ||
38 | private: | 40 | private: |
39 | ManufacturerDB* _manufacturerdb; | 41 | ManufacturerDB* _manufacturerdb; |
40 | 42 | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | #endif | 45 | #endif |
44 | 46 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index bfa7aa9..4aecd2b 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp | |||
@@ -1,102 +1,121 @@ | |||
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 "scanlistitem.h" | 16 | #include "scanlistitem.h" |
17 | #include <assert.h> | 17 | #include <assert.h> |
18 | #include <qdatetime.h> | 18 | #include <qdatetime.h> |
19 | #include <qpixmap.h> | 19 | #include <qpixmap.h> |
20 | 20 | ||
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #else | 23 | #else |
24 | #include "resource.h" | 24 | #include "resource.h" |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | const int col_type = 0; | 27 | const int col_type = 0; |
28 | const int col_essid = 0; | 28 | const int col_essid = 0; |
29 | const int col_sig = 1; | 29 | const int col_sig = 1; |
30 | const int col_ap = 2; | 30 | const int col_ap = 2; |
31 | const int col_channel = 3; | 31 | const int col_channel = 3; |
32 | const int col_wep = 4; | 32 | const int col_wep = 4; |
33 | const int col_traffic = 5; | 33 | const int col_traffic = 5; |
34 | const int col_manuf = 6; | 34 | const int col_manuf = 6; |
35 | const int col_firstseen = 7; | 35 | const int col_firstseen = 7; |
36 | const int col_lastseen = 8; | 36 | const int col_lastseen = 8; |
37 | 37 | ||
38 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 38 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
39 | bool wep, int channel, int signal ) | 39 | bool wep, int channel, int signal ) |
40 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 40 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
41 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 41 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
42 | _channel( channel ), _signal( signal ), _beacons( 0 ) | 42 | _channel( channel ), _signal( signal ), _beacons( 0 ) |
43 | { | 43 | { |
44 | qDebug( "creating scanlist item" ); | 44 | qDebug( "creating scanlist item" ); |
45 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 45 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
46 | } | 46 | } |
47 | 47 | ||
48 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 48 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
49 | bool wep, int channel, int signal ) | 49 | bool wep, int channel, int signal ) |
50 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 50 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
51 | { | 51 | { |
52 | qDebug( "creating scanlist item" ); | 52 | qDebug( "creating scanlist item" ); |
53 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 53 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
54 | } | 54 | } |
55 | 55 | ||
56 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 56 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
57 | { | 57 | { |
58 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 58 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
59 | (const char*) type, | 59 | (const char*) type, |
60 | (const char*) essid, | 60 | (const char*) essid, |
61 | (const char*) macaddr, | 61 | (const char*) macaddr, |
62 | channel ); | 62 | channel ); |
63 | 63 | ||
64 | // set icon for managed or adhoc mode | 64 | // set icon for managed or adhoc mode |
65 | QString name; | 65 | QString name; |
66 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 66 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
67 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 67 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
68 | 68 | ||
69 | // set icon for wep (wireless encryption protocol) | 69 | // set icon for wep (wireless encryption protocol) |
70 | if ( wep ) | 70 | if ( wep ) |
71 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 71 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
72 | 72 | ||
73 | // set channel and signal text | 73 | // set channel and signal text |
74 | 74 | ||
75 | if ( signal != -1 ) | 75 | if ( signal != -1 ) |
76 | setText( col_sig, QString::number( signal ) ); | 76 | setText( col_sig, QString::number( signal ) ); |
77 | if ( channel != -1 ) | 77 | if ( channel != -1 ) |
78 | setText( col_channel, QString::number( channel ) ); | 78 | setText( col_channel, QString::number( channel ) ); |
79 | 79 | ||
80 | setText( col_firstseen, QTime::currentTime().toString() ); | 80 | setText( col_firstseen, QTime::currentTime().toString() ); |
81 | //setText( col_lastseen, QTime::currentTime().toString() ); | 81 | //setText( col_lastseen, QTime::currentTime().toString() ); |
82 | 82 | ||
83 | listView()->triggerUpdate(); | 83 | listView()->triggerUpdate(); |
84 | 84 | ||
85 | this->type = type; | 85 | this->type = type; |
86 | 86 | _type = type; | |
87 | _essid = essid; | ||
88 | _macaddr = macaddr; | ||
89 | _channel = channel; | ||
90 | _beacons = 0; | ||
91 | _signal = 0; | ||
87 | } | 92 | } |
88 | 93 | ||
89 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 94 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
90 | { | 95 | { |
91 | setText( col_manuf, manufacturer ); | 96 | setText( col_manuf, manufacturer ); |
92 | } | 97 | } |
93 | 98 | ||
94 | void MScanListItem::receivedBeacon() | 99 | void MScanListItem::receivedBeacon() |
95 | { | 100 | { |
96 | _beacons++; | 101 | _beacons++; |
97 | #ifdef DEBUG | 102 | #ifdef DEBUG |
98 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 103 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
99 | #endif | 104 | #endif |
100 | setText( col_sig, QString::number( _beacons ) ); | 105 | setText( col_sig, QString::number( _beacons ) ); |
101 | setText( col_lastseen, QTime::currentTime().toString() ); | 106 | setText( col_lastseen, QTime::currentTime().toString() ); |
102 | } | 107 | } |
108 | |||
109 | void MScanListItem::dump( QTextStream& t ) const | ||
110 | { | ||
111 | qDebug( "dumping scanlistitem at <%d>", this ); | ||
112 | t << "<ITEM type=" << _type; | ||
113 | t << " ESSID='" << _essid; | ||
114 | t << "' MAC=" << _macaddr; | ||
115 | t << " WEP=" << _wep; | ||
116 | t << " CHANNEL=" << _channel; | ||
117 | t << " SIGNAL=" << _signal; | ||
118 | t << " BEACONS=" << _beacons; | ||
119 | t << ">\n"; | ||
120 | } | ||
121 | |||
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index 89b3bc4..5f6ae40 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h | |||
@@ -1,79 +1,83 @@ | |||
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 | #ifndef SCANLISTITEM_H | 16 | #ifndef SCANLISTITEM_H |
17 | #define SCANLISTITEM_H | 17 | #define SCANLISTITEM_H |
18 | 18 | ||
19 | #include <cornucopia/olistview.h> | 19 | #include <cornucopia/olistview.h> |
20 | 20 | ||
21 | #include <qtextstream.h> | ||
22 | |||
21 | class QString; | 23 | class QString; |
22 | 24 | ||
23 | class MScanListItem: public OListViewItem | 25 | class MScanListItem: public OListViewItem |
24 | { | 26 | { |
25 | public: | 27 | public: |
26 | 28 | ||
27 | MScanListItem::MScanListItem( QListView* parent, | 29 | MScanListItem::MScanListItem( QListView* parent, |
28 | QString type, | 30 | QString type, |
29 | QString essid, | 31 | QString essid, |
30 | QString macaddr, | 32 | QString macaddr, |
31 | bool wep, | 33 | bool wep, |
32 | int channel, | 34 | int channel, |
33 | int signal ); | 35 | int signal ); |
34 | 36 | ||
35 | MScanListItem::MScanListItem( QListViewItem* parent, | 37 | MScanListItem::MScanListItem( QListViewItem* parent, |
36 | QString type, | 38 | QString type, |
37 | QString essid, | 39 | QString essid, |
38 | QString macaddr, | 40 | QString macaddr, |
39 | bool wep, | 41 | bool wep, |
40 | int channel, | 42 | int channel, |
41 | int signal ); | 43 | int signal ); |
42 | 44 | ||
43 | 45 | ||
44 | protected: | 46 | protected: |
45 | 47 | ||
46 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 48 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); |
47 | 49 | ||
48 | public: | 50 | public: |
49 | 51 | ||
50 | QString type; | 52 | QString type; |
51 | 53 | ||
52 | public: | 54 | public: |
53 | 55 | ||
54 | //const QString& type() { return _type; }; | 56 | //const QString& type() { return _type; }; |
55 | const QString& essid() { return _essid; }; | 57 | const QString& essid() { return _essid; }; |
56 | const QString& macaddr() { return _macaddr; }; | 58 | const QString& macaddr() { return _macaddr; }; |
57 | bool wep() { return _wep; }; | 59 | bool wep() { return _wep; }; |
58 | int channel() { return _channel; }; | 60 | int channel() { return _channel; }; |
59 | int signal() { return _signal; }; | 61 | int signal() { return _signal; }; |
60 | int beacons() { return _beacons; }; | 62 | int beacons() { return _beacons; }; |
61 | 63 | ||
62 | void setSignal( int signal ) { /* TODO */ }; | 64 | void setSignal( int signal ) { /* TODO */ }; |
63 | void receivedBeacon(); | 65 | void receivedBeacon(); |
64 | 66 | ||
65 | void setManufacturer( const QString& manufacturer ); | 67 | void setManufacturer( const QString& manufacturer ); |
66 | 68 | ||
69 | void dump( QTextStream& t ) const; | ||
70 | |||
67 | private: | 71 | private: |
68 | QString _type; | 72 | QString _type; |
69 | QString _essid; | 73 | QString _essid; |
70 | QString _macaddr; | 74 | QString _macaddr; |
71 | bool _wep; | 75 | bool _wep; |
72 | int _channel; | 76 | int _channel; |
73 | int _signal; | 77 | int _signal; |
74 | int _beacons; | 78 | int _beacons; |
75 | 79 | ||
76 | }; | 80 | }; |
77 | 81 | ||
78 | #endif | 82 | #endif |
79 | 83 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index c599bb4..1ccf971 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,253 +1,258 @@ | |||
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 | // Qt | 16 | // Qt |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | #include <qsocketnotifier.h> | 22 | #include <qsocketnotifier.h> |
23 | 23 | ||
24 | // Qtopia | 24 | // Qtopia |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | // Opie | 31 | // Opie |
32 | 32 | ||
33 | #ifdef QWS | 33 | #ifdef QWS |
34 | #include <opie/odevice.h> | 34 | #include <opie/odevice.h> |
35 | using namespace Opie; | 35 | using namespace Opie; |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | // Standard | 38 | // Standard |
39 | 39 | ||
40 | #include <assert.h> | 40 | #include <assert.h> |
41 | #include <errno.h> | 41 | #include <errno.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <string.h> | 43 | #include <string.h> |
44 | #include <sys/types.h> | 44 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 45 | #include <sys/socket.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | 48 | ||
49 | // Local | 49 | // Local |
50 | 50 | ||
51 | #include "wellenreiter.h" | 51 | #include "wellenreiter.h" |
52 | #include "scanlist.h" | 52 | #include "scanlist.h" |
53 | #include "logwindow.h" | 53 | #include "logwindow.h" |
54 | #include "hexwindow.h" | 54 | #include "hexwindow.h" |
55 | #include "configwindow.h" | 55 | #include "configwindow.h" |
56 | 56 | ||
57 | #include "manufacturers.h" | 57 | #include "manufacturers.h" |
58 | 58 | ||
59 | #include <daemon/source/config.hh> | 59 | #include <daemon/source/config.hh> |
60 | #include <libwellenreiter/source/wl_types.hh> | 60 | #include <libwellenreiter/source/wl_types.hh> |
61 | #include <libwellenreiter/source/wl_sock.hh> | 61 | #include <libwellenreiter/source/wl_sock.hh> |
62 | #include <libwellenreiter/source/wl_proto.hh> | 62 | #include <libwellenreiter/source/wl_proto.hh> |
63 | 63 | ||
64 | Wellenreiter::Wellenreiter( QWidget* parent ) | 64 | Wellenreiter::Wellenreiter( QWidget* parent ) |
65 | : WellenreiterBase( parent, 0, 0 ), | 65 | : WellenreiterBase( parent, 0, 0 ), |
66 | daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) | 66 | daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) |
67 | { | 67 | { |
68 | 68 | ||
69 | // | 69 | // |
70 | // construct manufacturer database | 70 | // construct manufacturer database |
71 | // | 71 | // |
72 | 72 | ||
73 | QString manufile; | 73 | QString manufile; |
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 75 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
76 | #else | 76 | #else |
77 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 77 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
78 | #endif | 78 | #endif |
79 | manufacturerdb = new ManufacturerDB( manufile ); | 79 | manufacturerdb = new ManufacturerDB( manufile ); |
80 | 80 | ||
81 | logwindow->log( "(i) Wellenreiter has been started." ); | 81 | logwindow->log( "(i) Wellenreiter has been started." ); |
82 | 82 | ||
83 | // | 83 | // |
84 | // detect operating system | 84 | // detect operating system |
85 | // | 85 | // |
86 | 86 | ||
87 | #ifdef QWS | 87 | #ifdef QWS |
88 | QString sys; | 88 | QString sys; |
89 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 89 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
90 | _system = ODevice::inst()->system(); | 90 | _system = ODevice::inst()->system(); |
91 | logwindow->log( sys ); | 91 | logwindow->log( sys ); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | // | 94 | // |
95 | // setup socket for daemon communication, register socket notifier | 95 | // setup socket for daemon communication, register socket notifier |
96 | // | 96 | // |
97 | 97 | ||
98 | // struct sockaddr_in sockaddr; | 98 | // struct sockaddr_in sockaddr; |
99 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); | 99 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); |
100 | if ( daemon_fd == -1 ) | 100 | if ( daemon_fd == -1 ) |
101 | { | 101 | { |
102 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); | 102 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); |
103 | } | 103 | } |
104 | else | 104 | else |
105 | { | 105 | { |
106 | int flags; | 106 | int flags; |
107 | flags = fcntl( daemon_fd, F_GETFL, 0 ); | 107 | flags = fcntl( daemon_fd, F_GETFL, 0 ); |
108 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); | 108 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); |
109 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); | 109 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); |
110 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); | 110 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); |
111 | } | 111 | } |
112 | 112 | ||
113 | // setup GUI | 113 | // setup GUI |
114 | netview->setColumnWidthMode( 1, QListView::Manual ); | 114 | netview->setColumnWidthMode( 1, QListView::Manual ); |
115 | 115 | ||
116 | if ( manufacturerdb ) | 116 | if ( manufacturerdb ) |
117 | netview->setManufacturerDB( manufacturerdb ); | 117 | netview->setManufacturerDB( manufacturerdb ); |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
121 | Wellenreiter::~Wellenreiter() | 121 | Wellenreiter::~Wellenreiter() |
122 | { | 122 | { |
123 | // no need to delete child widgets, Qt does it all for us | 123 | // no need to delete child widgets, Qt does it all for us |
124 | 124 | ||
125 | delete manufacturerdb; | 125 | delete manufacturerdb; |
126 | if ( daemon_fd != -1 ) | ||
127 | { | ||
128 | qDebug( "closing comm socket" ); | ||
129 | close( daemon_fd ); | ||
130 | } | ||
126 | } | 131 | } |
127 | 132 | ||
128 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 133 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
129 | { | 134 | { |
130 | configwindow = cw; | 135 | configwindow = cw; |
131 | } | 136 | } |
132 | 137 | ||
133 | void Wellenreiter::handleMessage() | 138 | void Wellenreiter::handleMessage() |
134 | { | 139 | { |
135 | // FIXME: receive message and handle it | 140 | // FIXME: receive message and handle it |
136 | 141 | ||
137 | qDebug( "received message from daemon." ); | 142 | qDebug( "received message from daemon." ); |
138 | 143 | ||
139 | /*char buffer[10000]; | 144 | /*char buffer[10000]; |
140 | memset( &buffer, 0, sizeof( buffer ) );*/ | 145 | memset( &buffer, 0, sizeof( buffer ) );*/ |
141 | 146 | ||
142 | char buffer[WL_SOCKBUF]; | 147 | char buffer[WL_SOCKBUF]; |
143 | 148 | ||
144 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | 149 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); |
145 | 150 | ||
146 | /* | 151 | /* |
147 | 152 | ||
148 | struct sockaddr from; | 153 | struct sockaddr from; |
149 | socklen_t len; | 154 | socklen_t len; |
150 | 155 | ||
151 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); | 156 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); |
152 | qDebug( "received %d from recv [%d bytes]", result, len ); | 157 | qDebug( "received %d from recv [%d bytes]", result, len ); |
153 | 158 | ||
154 | */ | 159 | */ |
155 | 160 | ||
156 | int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); | 161 | int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); |
157 | 162 | ||
158 | if ( result == -1 ) | 163 | if ( result == -1 ) |
159 | { | 164 | { |
160 | qDebug( "Warning: %s", strerror( errno ) ); | 165 | qDebug( "Warning: %s", strerror( errno ) ); |
161 | return; | 166 | return; |
162 | } | 167 | } |
163 | 168 | ||
164 | int command = buffer[1] - 48; | 169 | int command = buffer[1] - 48; |
165 | 170 | ||
166 | /* | 171 | /* |
167 | typedef struct { | 172 | typedef struct { |
168 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc | 173 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc |
169 | int ssid_len; Length of SSID | 174 | int ssid_len; Length of SSID |
170 | int channel; Channel | 175 | int channel; Channel |
171 | int wep; 1 = WEP enabled ; 0 = disabled | 176 | int wep; 1 = WEP enabled ; 0 = disabled |
172 | char mac[64]; MAC address of Accesspoint | 177 | char mac[64]; MAC address of Accesspoint |
173 | char bssid[128]; BSSID of Accesspoint | 178 | char bssid[128]; BSSID of Accesspoint |
174 | } wl_network_t; | 179 | } wl_network_t; |
175 | */ | 180 | */ |
176 | 181 | ||
177 | qDebug( "Recv result: %d", ( result ) ); | 182 | qDebug( "Recv result: %d", ( result ) ); |
178 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); | 183 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); |
179 | hexwindow->log( (const char*) &buffer ); | 184 | hexwindow->log( (const char*) &buffer ); |
180 | 185 | ||
181 | if ( command == NETFOUND ) /* new network found */ | 186 | if ( command == NETFOUND ) /* new network found */ |
182 | { | 187 | { |
183 | qDebug( "Sniffer said: new network found." ); | 188 | qDebug( "Sniffer said: new network found." ); |
184 | wl_network_t n; | 189 | wl_network_t n; |
185 | get_network_found( &n, (char*) &buffer ); | 190 | get_network_found( &n, (char*) &buffer ); |
186 | 191 | ||
187 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); | 192 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); |
188 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); | 193 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); |
189 | 194 | ||
190 | //n.bssid[n.ssid_len] = "\0"; | 195 | //n.bssid[n.ssid_len] = "\0"; |
191 | 196 | ||
192 | QString type; | 197 | QString type; |
193 | 198 | ||
194 | if ( n.net_type == 1 ) | 199 | if ( n.net_type == 1 ) |
195 | type = "managed"; | 200 | type = "managed"; |
196 | else | 201 | else |
197 | type = "adhoc"; | 202 | type = "adhoc"; |
198 | 203 | ||
199 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); | 204 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); |
200 | 205 | ||
201 | } | 206 | } |
202 | 207 | ||
203 | else | 208 | else |
204 | 209 | ||
205 | { | 210 | { |
206 | qDebug( "unknown sniffer command." ); | 211 | qDebug( "unknown sniffer command." ); |
207 | } | 212 | } |
208 | 213 | ||
209 | } | 214 | } |
210 | 215 | ||
211 | void Wellenreiter::dataReceived() | 216 | void Wellenreiter::dataReceived() |
212 | { | 217 | { |
213 | logwindow->log( "(d) Received data from daemon" ); | 218 | logwindow->log( "(d) Received data from daemon" ); |
214 | handleMessage(); | 219 | handleMessage(); |
215 | } | 220 | } |
216 | 221 | ||
217 | void Wellenreiter::startStopClicked() | 222 | void Wellenreiter::startStopClicked() |
218 | { | 223 | { |
219 | if ( daemonRunning ) | 224 | if ( daemonRunning ) |
220 | { | 225 | { |
221 | daemonRunning = false; | 226 | daemonRunning = false; |
222 | 227 | ||
223 | logwindow->log( "(i) Daemon has been stopped." ); | 228 | logwindow->log( "(i) Daemon has been stopped." ); |
224 | setCaption( tr( "Wellenreiter/Opie" ) ); | 229 | setCaption( tr( "Wellenreiter/Opie" ) ); |
225 | 230 | ||
226 | // Stop daemon - ugly for now... later better | 231 | // Stop daemon - ugly for now... later better |
227 | 232 | ||
228 | system( "killall wellenreiterd" ); | 233 | system( "killall wellenreiterd" ); |
229 | 234 | ||
230 | // get configuration from config window | 235 | // get configuration from config window |
231 | 236 | ||
232 | const QString& interface = configwindow->interfaceName->currentText(); | 237 | const QString& interface = configwindow->interfaceName->currentText(); |
233 | 238 | ||
234 | // reset the interface trying to get it into a usable state again | 239 | // reset the interface trying to get it into a usable state again |
235 | 240 | ||
236 | QString cmdline; | 241 | QString cmdline; |
237 | cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); | 242 | cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); |
238 | system( cmdline ); | 243 | system( cmdline ); |
239 | 244 | ||
240 | // message the user | 245 | // message the user |
241 | 246 | ||
242 | QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); | 247 | QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); |
243 | } | 248 | } |
244 | 249 | ||
245 | else | 250 | else |
246 | { | 251 | { |
247 | 252 | ||
248 | // get configuration from config window | 253 | // get configuration from config window |
249 | 254 | ||
250 | const QString& interface = configwindow->interfaceName->currentText(); | 255 | const QString& interface = configwindow->interfaceName->currentText(); |
251 | const int cardtype = configwindow->daemonDeviceType(); | 256 | const int cardtype = configwindow->daemonDeviceType(); |
252 | const int interval = configwindow->daemonHopInterval(); | 257 | const int interval = configwindow->daemonHopInterval(); |
253 | 258 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index ff523d4..ee9dca9 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -1,81 +1,82 @@ | |||
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 | #ifndef WELLENREITER_H | 16 | #ifndef WELLENREITER_H |
17 | #define WELLENREITER_H | 17 | #define WELLENREITER_H |
18 | 18 | ||
19 | #include "wellenreiterbase.h" | 19 | #include "wellenreiterbase.h" |
20 | 20 | ||
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie/odevice.h> | 22 | #include <opie/odevice.h> |
23 | using namespace Opie; | 23 | using namespace Opie; |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | // ugly... not here! | 26 | // ugly... not here! |
27 | 27 | ||
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <sys/socket.h> | 33 | #include <sys/socket.h> |
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <daemon/source/config.hh> | 36 | #include <daemon/source/config.hh> |
37 | #include <libwellenreiter/source/wl_types.hh> | 37 | #include <libwellenreiter/source/wl_types.hh> |
38 | #include <libwellenreiter/source/wl_sock.hh> | 38 | #include <libwellenreiter/source/wl_sock.hh> |
39 | #include <libwellenreiter/source/wl_proto.hh> | 39 | #include <libwellenreiter/source/wl_proto.hh> |
40 | 40 | ||
41 | class QTimerEvent; | 41 | class QTimerEvent; |
42 | class QPixmap; | 42 | class QPixmap; |
43 | class ManufacturerDB; | 43 | class ManufacturerDB; |
44 | class WellenreiterConfigWindow; | 44 | class WellenreiterConfigWindow; |
45 | 45 | ||
46 | class Wellenreiter : public WellenreiterBase { | 46 | class Wellenreiter : public WellenreiterBase { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | 48 | ||
49 | public: | 49 | public: |
50 | Wellenreiter( QWidget* parent = 0 ); | 50 | Wellenreiter( QWidget* parent = 0 ); |
51 | ~Wellenreiter(); | 51 | ~Wellenreiter(); |
52 | 52 | ||
53 | void setConfigWindow( WellenreiterConfigWindow* cw ); | 53 | void setConfigWindow( WellenreiterConfigWindow* cw ); |
54 | MScanListView* netView() const { return netview; }; | 54 | MScanListView* netView() const { return netview; }; |
55 | MLogWindow* logWindow() const { return logwindow; }; | 55 | MLogWindow* logWindow() const { return logwindow; }; |
56 | bool isDaemonRunning() const { return daemonRunning; }; | ||
56 | 57 | ||
57 | protected: | 58 | protected: |
58 | bool daemonRunning; | 59 | bool daemonRunning; |
59 | 60 | ||
60 | public slots: | 61 | public slots: |
61 | void dataReceived(); | 62 | void dataReceived(); |
62 | void startStopClicked(); | 63 | void startStopClicked(); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | int daemon_fd; // socket filedescriptor for udp communication socket | 66 | int daemon_fd; // socket filedescriptor for udp communication socket |
66 | #ifdef QWS | 67 | #ifdef QWS |
67 | OSystem _system; // Opie Operating System identifier | 68 | OSystem _system; // Opie Operating System identifier |
68 | #endif | 69 | #endif |
69 | void handleMessage(); | 70 | void handleMessage(); |
70 | 71 | ||
71 | ManufacturerDB* manufacturerdb; | 72 | ManufacturerDB* manufacturerdb; |
72 | WellenreiterConfigWindow* configwindow; | 73 | WellenreiterConfigWindow* configwindow; |
73 | struct sockaddr_in sockaddr; | 74 | struct sockaddr_in sockaddr; |
74 | 75 | ||
75 | //void readConfig(); | 76 | //void readConfig(); |
76 | //void writeConfig(); | 77 | //void writeConfig(); |
77 | }; | 78 | }; |
78 | 79 | ||
79 | 80 | ||
80 | 81 | ||
81 | #endif | 82 | #endif |