author | mickeyl <mickeyl> | 2003-06-26 10:34:59 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-06-26 10:34:59 (UTC) |
commit | 8168239a5b1ff80abc02f93ed831c088ca5f2f3d (patch) (unidiff) | |
tree | d19069b730eeb82f02754955366569d52d088248 | |
parent | 3c5746daa26d8353fde9ba84c6183517e26a625a (diff) | |
download | opie-8168239a5b1ff80abc02f93ed831c088ca5f2f3d.zip opie-8168239a5b1ff80abc02f93ed831c088ca5f2f3d.tar.gz opie-8168239a5b1ff80abc02f93ed831c088ca5f2f3d.tar.bz2 |
first bunch of fixes for Qt 3.x compilation
-rw-r--r-- | libopie2/opieui/olistview.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 9 |
4 files changed, 12 insertions, 2 deletions
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h index 1bbdd5b..109e309 100644 --- a/libopie2/opieui/olistview.h +++ b/libopie2/opieui/olistview.h | |||
@@ -1,296 +1,298 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef OLISTVIEW_H | 31 | #ifndef OLISTVIEW_H |
32 | #define OLISTVIEW_H | 32 | #define OLISTVIEW_H |
33 | 33 | ||
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qpen.h> | 36 | #include <qpen.h> |
37 | #include <qdatastream.h> | 37 | #include <qdatastream.h> |
38 | #include <qstringlist.h> | ||
38 | 39 | ||
39 | class OListViewItem; | 40 | class OListViewItem; |
40 | 41 | ||
42 | |||
41 | /*====================================================================================== | 43 | /*====================================================================================== |
42 | * OListView | 44 | * OListView |
43 | *======================================================================================*/ | 45 | *======================================================================================*/ |
44 | 46 | ||
45 | /** | 47 | /** |
46 | * @brief A list/tree widget. | 48 | * @brief A list/tree widget. |
47 | * | 49 | * |
48 | * A @ref QListView variant featuring visual and functional enhancements | 50 | * A @ref QListView variant featuring visual and functional enhancements |
49 | * like an alternate background for odd rows, an autostretch mode | 51 | * like an alternate background for odd rows, an autostretch mode |
50 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | 52 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
51 | * | 53 | * |
52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 54 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
53 | */ | 55 | */ |
54 | class OListView: public QListView | 56 | class OListView: public QListView |
55 | { | 57 | { |
56 | public: | 58 | public: |
57 | /** | 59 | /** |
58 | * Constructor. | 60 | * Constructor. |
59 | * | 61 | * |
60 | * The parameters @a parent and @a name are handled by | 62 | * The parameters @a parent and @a name are handled by |
61 | * @ref QListView, as usual. | 63 | * @ref QListView, as usual. |
62 | */ | 64 | */ |
63 | OListView( QWidget* parent = 0, const char* name = 0 ); | 65 | OListView( QWidget* parent = 0, const char* name = 0 ); |
64 | /** | 66 | /** |
65 | * Destructor. | 67 | * Destructor. |
66 | */ | 68 | */ |
67 | virtual ~OListView(); | 69 | virtual ~OListView(); |
68 | /** | 70 | /** |
69 | * Let the last column fit exactly all the available width. | 71 | * Let the last column fit exactly all the available width. |
70 | */ | 72 | */ |
71 | void setFullWidth( bool fullWidth ); | 73 | void setFullWidth( bool fullWidth ); |
72 | /** | 74 | /** |
73 | * Returns whether the last column is set to fit the available width. | 75 | * Returns whether the last column is set to fit the available width. |
74 | */ | 76 | */ |
75 | bool fullWidth() const; | 77 | bool fullWidth() const; |
76 | /** | 78 | /** |
77 | * Reimplemented for full width support | 79 | * Reimplemented for full width support |
78 | */ | 80 | */ |
79 | virtual int addColumn( const QString& label, int width = -1 ); | 81 | virtual int addColumn( const QString& label, int width = -1 ); |
80 | /** | 82 | /** |
81 | * Reimplemented for full width support | 83 | * Reimplemented for full width support |
82 | */ | 84 | */ |
83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | 85 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); |
84 | /** | 86 | /** |
85 | * Reimplemented for full width support | 87 | * Reimplemented for full width support |
86 | */ | 88 | */ |
87 | virtual void removeColumn(int index); | 89 | virtual void removeColumn(int index); |
88 | /** | 90 | /** |
89 | * Set the alternate background background @a color. | 91 | * Set the alternate background background @a color. |
90 | * Set to an invalid color to disable alternate colors. | 92 | * Set to an invalid color to disable alternate colors. |
91 | * This only has an effect if the items are OListViewItems | 93 | * This only has an effect if the items are OListViewItems |
92 | */ | 94 | */ |
93 | void setAlternateBackground( const QColor& color ); | 95 | void setAlternateBackground( const QColor& color ); |
94 | /** | 96 | /** |
95 | * Sets the column separator @a pen. | 97 | * Sets the column separator @a pen. |
96 | */ | 98 | */ |
97 | void setColumnSeparator( const QPen& pen ); | 99 | void setColumnSeparator( const QPen& pen ); |
98 | 100 | ||
99 | /** | 101 | /** |
100 | * @returns the alternate background color | 102 | * @returns the alternate background color |
101 | */ | 103 | */ |
102 | const QColor& alternateBackground() const; | 104 | const QColor& alternateBackground() const; |
103 | /** | 105 | /** |
104 | * @return the column separator pen | 106 | * @return the column separator pen |
105 | */ | 107 | */ |
106 | const QPen& columnSeparator() const; | 108 | const QPen& columnSeparator() const; |
107 | /** | 109 | /** |
108 | * Create a list view item as child of this object | 110 | * Create a list view item as child of this object |
109 | * @returns the new object | 111 | * @returns the new object |
110 | */ | 112 | */ |
111 | virtual OListViewItem* childFactory(); | 113 | virtual OListViewItem* childFactory(); |
112 | #ifndef QT_NO_DATASTREAM | 114 | #ifndef QT_NO_DATASTREAM |
113 | /** | 115 | /** |
114 | * Serialize this object to @ref QDataStream @a stream | 116 | * Serialize this object to @ref QDataStream @a stream |
115 | */ | 117 | */ |
116 | virtual void serializeTo( QDataStream& stream ) const; | 118 | virtual void serializeTo( QDataStream& stream ) const; |
117 | /** | 119 | /** |
118 | * Serialize this object from a @ref QDataStream @a stream | 120 | * Serialize this object from a @ref QDataStream @a stream |
119 | */ | 121 | */ |
120 | virtual void serializeFrom( QDataStream& s ); | 122 | virtual void serializeFrom( QDataStream& s ); |
121 | #endif | 123 | #endif |
122 | 124 | ||
123 | private: | 125 | private: |
124 | QColor m_alternateBackground; | 126 | QColor m_alternateBackground; |
125 | bool m_fullWidth; | 127 | bool m_fullWidth; |
126 | QPen m_columnSeparator; | 128 | QPen m_columnSeparator; |
127 | }; | 129 | }; |
128 | 130 | ||
129 | #ifndef QT_NO_DATASTREAM | 131 | #ifndef QT_NO_DATASTREAM |
130 | /** | 132 | /** |
131 | * @relates OListView | 133 | * @relates OListView |
132 | * Writes @a listview to the @a stream and returns a reference to the stream. | 134 | * Writes @a listview to the @a stream and returns a reference to the stream. |
133 | */ | 135 | */ |
134 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); | 136 | QDataStream& operator<<( QDataStream& stream, const OListView& listview ); |
135 | /** | 137 | /** |
136 | * @relates OListView | 138 | * @relates OListView |
137 | * Reads @a listview from the @a stream and returns a reference to the stream. | 139 | * Reads @a listview from the @a stream and returns a reference to the stream. |
138 | */ | 140 | */ |
139 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); | 141 | QDataStream& operator>>( QDataStream& stream, OListView& listview ); |
140 | #endif // QT_NO_DATASTREAM | 142 | #endif // QT_NO_DATASTREAM |
141 | 143 | ||
142 | /*====================================================================================== | 144 | /*====================================================================================== |
143 | * OListViewItem | 145 | * OListViewItem |
144 | *======================================================================================*/ | 146 | *======================================================================================*/ |
145 | 147 | ||
146 | class OListViewItem: public QListViewItem | 148 | class OListViewItem: public QListViewItem |
147 | { | 149 | { |
148 | public: | 150 | public: |
149 | /** | 151 | /** |
150 | * Constructors. | 152 | * Constructors. |
151 | */ | 153 | */ |
152 | OListViewItem( QListView * parent ); | 154 | OListViewItem( QListView * parent ); |
153 | OListViewItem( QListViewItem * parent ); | 155 | OListViewItem( QListViewItem * parent ); |
154 | OListViewItem( QListView * parent, QListViewItem * after ); | 156 | OListViewItem( QListView * parent, QListViewItem * after ); |
155 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 157 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
156 | 158 | ||
157 | OListViewItem( QListView * parent, | 159 | OListViewItem( QListView * parent, |
158 | QString, QString = QString::null, | 160 | QString, QString = QString::null, |
159 | QString = QString::null, QString = QString::null, | 161 | QString = QString::null, QString = QString::null, |
160 | QString = QString::null, QString = QString::null, | 162 | QString = QString::null, QString = QString::null, |
161 | QString = QString::null, QString = QString::null ); | 163 | QString = QString::null, QString = QString::null ); |
162 | 164 | ||
163 | OListViewItem( QListViewItem * parent, | 165 | OListViewItem( QListViewItem * parent, |
164 | QString, QString = QString::null, | 166 | QString, QString = QString::null, |
165 | QString = QString::null, QString = QString::null, | 167 | QString = QString::null, QString = QString::null, |
166 | QString = QString::null, QString = QString::null, | 168 | QString = QString::null, QString = QString::null, |
167 | QString = QString::null, QString = QString::null ); | 169 | QString = QString::null, QString = QString::null ); |
168 | 170 | ||
169 | OListViewItem( QListView * parent, QListViewItem * after, | 171 | OListViewItem( QListView * parent, QListViewItem * after, |
170 | QString, QString = QString::null, | 172 | QString, QString = QString::null, |
171 | QString = QString::null, QString = QString::null, | 173 | QString = QString::null, QString = QString::null, |
172 | QString = QString::null, QString = QString::null, | 174 | QString = QString::null, QString = QString::null, |
173 | QString = QString::null, QString = QString::null ); | 175 | QString = QString::null, QString = QString::null ); |
174 | 176 | ||
175 | OListViewItem( QListViewItem * parent, QListViewItem * after, | 177 | OListViewItem( QListViewItem * parent, QListViewItem * after, |
176 | QString, QString = QString::null, | 178 | QString, QString = QString::null, |
177 | QString = QString::null, QString = QString::null, | 179 | QString = QString::null, QString = QString::null, |
178 | QString = QString::null, QString = QString::null, | 180 | QString = QString::null, QString = QString::null, |
179 | QString = QString::null, QString = QString::null ); | 181 | QString = QString::null, QString = QString::null ); |
180 | /** | 182 | /** |
181 | * Destructor. | 183 | * Destructor. |
182 | */ | 184 | */ |
183 | virtual ~OListViewItem(); | 185 | virtual ~OListViewItem(); |
184 | /** | 186 | /** |
185 | * @returns the background color of the list item. | 187 | * @returns the background color of the list item. |
186 | */ | 188 | */ |
187 | const QColor& backgroundColor(); | 189 | const QColor& backgroundColor(); |
188 | /** | 190 | /** |
189 | * @returns true, if the item is at an odd position and | 191 | * @returns true, if the item is at an odd position and |
190 | * thus have to be painted with the alternate background color. | 192 | * thus have to be painted with the alternate background color. |
191 | */ | 193 | */ |
192 | bool isAlternate(); | 194 | bool isAlternate(); |
193 | /** | 195 | /** |
194 | * @note: Reimplemented for internal purposes - the API is not affected | 196 | * @note: Reimplemented for internal purposes - the API is not affected |
195 | * | 197 | * |
196 | */ | 198 | */ |
197 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 199 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
198 | /** | 200 | /** |
199 | * Perform object initialization. | 201 | * Perform object initialization. |
200 | */ | 202 | */ |
201 | void init(); | 203 | void init(); |
202 | /** | 204 | /** |
203 | * create a list view item as child of this object | 205 | * create a list view item as child of this object |
204 | * @returns the new object | 206 | * @returns the new object |
205 | */ | 207 | */ |
206 | virtual OListViewItem* childFactory(); | 208 | virtual OListViewItem* childFactory(); |
207 | #ifndef QT_NO_DATASTREAM | 209 | #ifndef QT_NO_DATASTREAM |
208 | /** | 210 | /** |
209 | * serialize this object to or from a @ref QDataStream | 211 | * serialize this object to or from a @ref QDataStream |
210 | * @param s the stream used to serialize this object. | 212 | * @param s the stream used to serialize this object. |
211 | */ | 213 | */ |
212 | virtual void serializeTo( QDataStream& s ) const; | 214 | virtual void serializeTo( QDataStream& s ) const; |
213 | 215 | ||
214 | /** | 216 | /** |
215 | * serialize this object to or from a @ref QDataStream | 217 | * serialize this object to or from a @ref QDataStream |
216 | * @param s the stream used to serialize this object. | 218 | * @param s the stream used to serialize this object. |
217 | */ | 219 | */ |
218 | virtual void serializeFrom( QDataStream& s ); | 220 | virtual void serializeFrom( QDataStream& s ); |
219 | #endif | 221 | #endif |
220 | 222 | ||
221 | private: | 223 | private: |
222 | bool m_known; | 224 | bool m_known; |
223 | bool m_odd; | 225 | bool m_odd; |
224 | }; | 226 | }; |
225 | 227 | ||
226 | #ifndef QT_NO_DATASTREAM | 228 | #ifndef QT_NO_DATASTREAM |
227 | /** | 229 | /** |
228 | * @relates QListViewItem | 230 | * @relates QListViewItem |
229 | * Writes listview @a item and all subitems recursively to @a stream | 231 | * Writes listview @a item and all subitems recursively to @a stream |
230 | * and returns a reference to the stream. | 232 | * and returns a reference to the stream. |
231 | */ | 233 | */ |
232 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); | 234 | QDataStream& operator<<( QDataStream& stream, const OListViewItem& item ); |
233 | /** | 235 | /** |
234 | * @relates QListViewItem | 236 | * @relates QListViewItem |
235 | * Reads listview @a item from @a stream and returns a reference to the stream. | 237 | * Reads listview @a item from @a stream and returns a reference to the stream. |
236 | */ | 238 | */ |
237 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); | 239 | QDataStream& operator>>( QDataStream& stream, OListViewItem& item ); |
238 | #endif // QT_NO_DATASTREAM | 240 | #endif // QT_NO_DATASTREAM |
239 | 241 | ||
240 | /*====================================================================================== | 242 | /*====================================================================================== |
241 | * ONamedListView | 243 | * ONamedListView |
242 | *======================================================================================*/ | 244 | *======================================================================================*/ |
243 | 245 | ||
244 | class ONamedListViewItem; | 246 | class ONamedListViewItem; |
245 | 247 | ||
246 | /** | 248 | /** |
247 | * @brief An OListView variant with named columns. | 249 | * @brief An OListView variant with named columns. |
248 | * | 250 | * |
249 | * This class provides a higher-level interface to an OListView. | 251 | * This class provides a higher-level interface to an OListView. |
250 | * | 252 | * |
251 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 253 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
252 | */ | 254 | */ |
253 | class ONamedListView: public OListView | 255 | class ONamedListView: public OListView |
254 | { | 256 | { |
255 | public: | 257 | public: |
256 | /** | 258 | /** |
257 | * Constructor. | 259 | * Constructor. |
258 | * | 260 | * |
259 | * The parameters @a parent and @a name are handled by | 261 | * The parameters @a parent and @a name are handled by |
260 | * @ref OListView, as usual. | 262 | * @ref OListView, as usual. |
261 | */ | 263 | */ |
262 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); | 264 | ONamedListView( QWidget* parent = 0, const char* name = 0 ); |
263 | /** | 265 | /** |
264 | * Destructor. | 266 | * Destructor. |
265 | */ | 267 | */ |
266 | virtual ~ONamedListView(); | 268 | virtual ~ONamedListView(); |
267 | /** | 269 | /** |
268 | * Add a number of @a columns to the listview. | 270 | * Add a number of @a columns to the listview. |
269 | */ | 271 | */ |
270 | virtual void addColumns( const QStringList& columns ); | 272 | virtual void addColumns( const QStringList& columns ); |
271 | /** | 273 | /** |
272 | * @returns the column index matching to @a text or -1 if not found. | 274 | * @returns the column index matching to @a text or -1 if not found. |
273 | */ | 275 | */ |
274 | virtual int findColumn( const QString& text ) const; | 276 | virtual int findColumn( const QString& text ) const; |
275 | /** | 277 | /** |
276 | * @returns the first item which has a @a text in column @a column. | 278 | * @returns the first item which has a @a text in column @a column. |
277 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> | 279 | * Set @a recurse to indicate how much subchild levels to search, e.g.<ul> |
278 | * <li>set it to 0 to search only among direct childs, | 280 | * <li>set it to 0 to search only among direct childs, |
279 | * <li>set it to 1 to search direct childs and all 1st order subchilds | 281 | * <li>set it to 1 to search direct childs and all 1st order subchilds |
280 | * <li>set it to -1 for maximum recursion. | 282 | * <li>set it to -1 for maximum recursion. |
281 | * </ul> | 283 | * </ul> |
282 | * @sa ONamedListViewItem::find() | 284 | * @sa ONamedListViewItem::find() |
283 | */ | 285 | */ |
284 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; | 286 | virtual ONamedListViewItem* find( ONamedListViewItem* start, int column, const QString& text, int recurse = -1 ) const; |
285 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; | 287 | virtual ONamedListViewItem* find( int column, const QString& text, int recurse = -1 ) const; |
286 | 288 | ||
287 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; | 289 | virtual ONamedListViewItem* find( ONamedListViewItem* start, const QString& column, const QString& text, int recurse = -1 ) const; |
288 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; | 290 | virtual ONamedListViewItem* find( const QString& column, const QString& text, int recurse = -1 ) const; |
289 | }; | 291 | }; |
290 | 292 | ||
291 | /*====================================================================================== | 293 | /*====================================================================================== |
292 | * ONamedListViewItem | 294 | * ONamedListViewItem |
293 | *======================================================================================*/ | 295 | *======================================================================================*/ |
294 | 296 | ||
295 | /** | 297 | /** |
296 | * @brief An OListView variant with named columns. | 298 | * @brief An OListView variant with named columns. |
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 5bec7ed..11394d7 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -1,192 +1,192 @@ | |||
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 | /* LOCAL */ | 16 | /* LOCAL */ |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "mainwindow.h" | 18 | #include "mainwindow.h" |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qapplication.h> | 21 | #include <qapplication.h> |
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qcombobox.h> | 23 | #include <qcombobox.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/onetwork.h> | 34 | #include <opie2/onetwork.h> |
35 | 35 | ||
36 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 36 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
37 | 37 | ||
38 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 38 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
39 | :WellenreiterConfigBase( parent, name, true, f ) | 39 | :WellenreiterConfigBase( parent, name, true, f ) |
40 | { | 40 | { |
41 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 41 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
42 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 42 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
43 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 43 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
44 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 44 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
45 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 45 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
46 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 46 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
47 | 47 | ||
48 | // gather possible interface names from ONetwork | 48 | // gather possible interface names from ONetwork |
49 | ONetwork* net = ONetwork::instance(); | 49 | ONetwork* net = ONetwork::instance(); |
50 | ONetwork::InterfaceIterator it = net->iterator(); | 50 | ONetwork::InterfaceIterator it = net->iterator(); |
51 | while ( it.current() ) | 51 | while ( it.current() ) |
52 | { | 52 | { |
53 | if ( it.current()->isWireless() ) | 53 | if ( it.current()->isWireless() ) |
54 | interfaceName->insertItem( it.current()->name() ); | 54 | interfaceName->insertItem( it.current()->name() ); |
55 | ++it; | 55 | ++it; |
56 | } | 56 | } |
57 | 57 | ||
58 | // try to guess device type | 58 | // try to guess device type |
59 | QFile m( "/proc/modules" ); | 59 | QFile m( "/proc/modules" ); |
60 | if ( m.open( IO_ReadOnly ) ) | 60 | if ( m.open( IO_ReadOnly ) ) |
61 | { | 61 | { |
62 | int devicetype(0); | 62 | int devicetype(0); |
63 | QString line; | 63 | QString line; |
64 | QTextStream modules( &m ); | 64 | QTextStream modules( &m ); |
65 | while( !modules.atEnd() && !devicetype ) | 65 | while( !modules.atEnd() && !devicetype ) |
66 | { | 66 | { |
67 | modules >> line; | 67 | modules >> line; |
68 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 68 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
69 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 69 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
70 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 70 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
71 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 71 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
72 | } | 72 | } |
73 | if ( devicetype ) | 73 | if ( devicetype ) |
74 | { | 74 | { |
75 | deviceType->setCurrentItem( devicetype ); | 75 | deviceType->setCurrentItem( devicetype ); |
76 | _guess = devicetype; | 76 | _guess = devicetype; |
77 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 77 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | 81 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here |
82 | QPushButton* okButton = new QPushButton( "ok", this ); | 82 | QPushButton* okButton = new QPushButton( "ok", this ); |
83 | okButton->show(); | 83 | okButton->show(); |
84 | Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | 84 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui |
85 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 85 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | WellenreiterConfigWindow::_instance = this; | 88 | WellenreiterConfigWindow::_instance = this; |
89 | 89 | ||
90 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 90 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
91 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 91 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
92 | 92 | ||
93 | // make the checkbox 'channelAll' control all other channels | 93 | // make the checkbox 'channelAll' control all other channels |
94 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 94 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
95 | }; | 95 | }; |
96 | 96 | ||
97 | 97 | ||
98 | int WellenreiterConfigWindow::driverType() const | 98 | int WellenreiterConfigWindow::driverType() const |
99 | { | 99 | { |
100 | QString name = deviceType->currentText(); | 100 | QString name = deviceType->currentText(); |
101 | if ( _devicetype.contains( name ) ) | 101 | if ( _devicetype.contains( name ) ) |
102 | { | 102 | { |
103 | return _devicetype[name]; | 103 | return _devicetype[name]; |
104 | } | 104 | } |
105 | else | 105 | else |
106 | { | 106 | { |
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | }; | 109 | }; |
110 | 110 | ||
111 | 111 | ||
112 | int WellenreiterConfigWindow::hoppingInterval() const | 112 | int WellenreiterConfigWindow::hoppingInterval() const |
113 | { | 113 | { |
114 | return hopInterval->cleanText().toInt(); | 114 | return hopInterval->cleanText().toInt(); |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | bool WellenreiterConfigWindow::usePrismHeader() const | 118 | bool WellenreiterConfigWindow::usePrismHeader() const |
119 | { | 119 | { |
120 | return prismHeader->isOn(); | 120 | return prismHeader->isOn(); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const | 124 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const |
125 | { | 125 | { |
126 | switch ( channel ) | 126 | switch ( channel ) |
127 | { | 127 | { |
128 | case 1: return channel1->isOn(); | 128 | case 1: return channel1->isOn(); |
129 | case 2: return channel2->isOn(); | 129 | case 2: return channel2->isOn(); |
130 | case 3: return channel3->isOn(); | 130 | case 3: return channel3->isOn(); |
131 | case 4: return channel4->isOn(); | 131 | case 4: return channel4->isOn(); |
132 | case 5: return channel5->isOn(); | 132 | case 5: return channel5->isOn(); |
133 | case 6: return channel6->isOn(); | 133 | case 6: return channel6->isOn(); |
134 | case 7: return channel7->isOn(); | 134 | case 7: return channel7->isOn(); |
135 | case 8: return channel8->isOn(); | 135 | case 8: return channel8->isOn(); |
136 | case 9: return channel9->isOn(); | 136 | case 9: return channel9->isOn(); |
137 | case 10: return channel10->isOn(); | 137 | case 10: return channel10->isOn(); |
138 | case 11: return channel11->isOn(); | 138 | case 11: return channel11->isOn(); |
139 | case 12: return channel12->isOn(); | 139 | case 12: return channel12->isOn(); |
140 | case 13: return channel13->isOn(); | 140 | case 13: return channel13->isOn(); |
141 | case 14: return channel14->isOn(); | 141 | case 14: return channel14->isOn(); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void WellenreiterConfigWindow::changedDeviceType(int t) | 146 | void WellenreiterConfigWindow::changedDeviceType(int t) |
147 | { | 147 | { |
148 | if ( t != DEVTYPE_FILE ) return; | 148 | if ( t != DEVTYPE_FILE ) return; |
149 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); | 149 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); |
150 | if ( !name.isEmpty() && QFile::exists( name ) ) | 150 | if ( !name.isEmpty() && QFile::exists( name ) ) |
151 | { | 151 | { |
152 | interfaceName->insertItem( name ); | 152 | interfaceName->insertItem( name ); |
153 | interfaceName->setCurrentItem( interfaceName->count()-1 ); | 153 | interfaceName->setCurrentItem( interfaceName->count()-1 ); |
154 | } | 154 | } |
155 | else | 155 | else |
156 | { | 156 | { |
157 | deviceType->setCurrentItem( _guess ); | 157 | deviceType->setCurrentItem( _guess ); |
158 | } | 158 | } |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 163 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
164 | { | 164 | { |
165 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 165 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
166 | qDebug( "name = %s", (const char*) name ); | 166 | qDebug( "name = %s", (const char*) name ); |
167 | if ( !name.isEmpty() ) | 167 | if ( !name.isEmpty() ) |
168 | { | 168 | { |
169 | captureFileName->setText( name ); | 169 | captureFileName->setText( name ); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void WellenreiterConfigWindow::channelAllClicked(int state) | 174 | void WellenreiterConfigWindow::channelAllClicked(int state) |
175 | { | 175 | { |
176 | bool b = state; | 176 | bool b = state; |
177 | channel1->setChecked( b ); | 177 | channel1->setChecked( b ); |
178 | channel2->setChecked( b ); | 178 | channel2->setChecked( b ); |
179 | channel3->setChecked( b ); | 179 | channel3->setChecked( b ); |
180 | channel4->setChecked( b ); | 180 | channel4->setChecked( b ); |
181 | channel5->setChecked( b ); | 181 | channel5->setChecked( b ); |
182 | channel6->setChecked( b ); | 182 | channel6->setChecked( b ); |
183 | channel7->setChecked( b ); | 183 | channel7->setChecked( b ); |
184 | channel8->setChecked( b ); | 184 | channel8->setChecked( b ); |
185 | channel9->setChecked( b ); | 185 | channel9->setChecked( b ); |
186 | channel10->setChecked( b ); | 186 | channel10->setChecked( b ); |
187 | channel11->setChecked( b ); | 187 | channel11->setChecked( b ); |
188 | channel12->setChecked( b ); | 188 | channel12->setChecked( b ); |
189 | channel13->setChecked( b ); | 189 | channel13->setChecked( b ); |
190 | channel14->setChecked( b ); | 190 | channel14->setChecked( b ); |
191 | } | 191 | } |
192 | 192 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 085eec4..f4cfe52 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,276 +1,277 @@ | |||
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 "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | #include <qcursor.h> | ||
21 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
22 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
23 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
24 | 25 | ||
25 | #ifdef QWS | 26 | #ifdef QWS |
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
27 | #include <opie/odevice.h> | 28 | #include <opie/odevice.h> |
28 | using namespace Opie; | 29 | using namespace Opie; |
29 | #endif | 30 | #endif |
30 | 31 | ||
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 | const int col_type = 0; | 39 | const int col_type = 0; |
39 | const int col_essid = 0; | 40 | const int col_essid = 0; |
40 | const int col_sig = 1; | 41 | const int col_sig = 1; |
41 | const int col_ap = 2; | 42 | const int col_ap = 2; |
42 | const int col_channel = 3; | 43 | const int col_channel = 3; |
43 | const int col_wep = 4; | 44 | const int col_wep = 4; |
44 | const int col_traffic = 5; | 45 | const int col_traffic = 5; |
45 | const int col_ip = 6; | 46 | const int col_ip = 6; |
46 | const int col_manuf = 7; | 47 | const int col_manuf = 7; |
47 | const int col_firstseen = 8; | 48 | const int col_firstseen = 8; |
48 | const int col_lastseen = 9; | 49 | const int col_lastseen = 9; |
49 | 50 | ||
50 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 51 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
51 | :OListView( parent, name ) | 52 | :OListView( parent, name ) |
52 | { | 53 | { |
53 | 54 | ||
54 | setFrameShape( QListView::StyledPanel ); | 55 | setFrameShape( QListView::StyledPanel ); |
55 | setFrameShadow( QListView::Sunken ); | 56 | setFrameShadow( QListView::Sunken ); |
56 | 57 | ||
57 | addColumn( tr( "Net/Station" ) ); | 58 | addColumn( tr( "Net/Station" ) ); |
58 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 59 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
59 | addColumn( tr( "#" ) ); | 60 | addColumn( tr( "#" ) ); |
60 | setColumnAlignment( col_sig, AlignCenter ); | 61 | setColumnAlignment( col_sig, AlignCenter ); |
61 | addColumn( tr( "MAC" ) ); | 62 | addColumn( tr( "MAC" ) ); |
62 | setColumnAlignment( col_ap, AlignCenter ); | 63 | setColumnAlignment( col_ap, AlignCenter ); |
63 | addColumn( tr( "Chn" ) ); | 64 | addColumn( tr( "Chn" ) ); |
64 | setColumnAlignment( col_channel, AlignCenter ); | 65 | setColumnAlignment( col_channel, AlignCenter ); |
65 | addColumn( tr( "W" ) ); | 66 | addColumn( tr( "W" ) ); |
66 | setColumnAlignment( col_wep, AlignCenter ); | 67 | setColumnAlignment( col_wep, AlignCenter ); |
67 | addColumn( tr( "T" ) ); | 68 | addColumn( tr( "T" ) ); |
68 | setColumnAlignment( col_traffic, AlignCenter ); | 69 | setColumnAlignment( col_traffic, AlignCenter ); |
69 | addColumn( tr( "IP" ) ); | 70 | addColumn( tr( "IP" ) ); |
70 | setColumnAlignment( col_ip, AlignCenter ); | 71 | setColumnAlignment( col_ip, AlignCenter ); |
71 | addColumn( tr( "Manufacturer" ) ); | 72 | addColumn( tr( "Manufacturer" ) ); |
72 | setColumnAlignment( col_manuf, AlignCenter ); | 73 | setColumnAlignment( col_manuf, AlignCenter ); |
73 | addColumn( tr( "First Seen" ) ); | 74 | addColumn( tr( "First Seen" ) ); |
74 | setColumnAlignment( col_firstseen, AlignCenter ); | 75 | setColumnAlignment( col_firstseen, AlignCenter ); |
75 | addColumn( tr( "Last Seen" ) ); | 76 | addColumn( tr( "Last Seen" ) ); |
76 | setColumnAlignment( col_lastseen, AlignCenter ); | 77 | setColumnAlignment( col_lastseen, AlignCenter ); |
77 | setRootIsDecorated( true ); | 78 | setRootIsDecorated( true ); |
78 | setAllColumnsShowFocus( true ); | 79 | setAllColumnsShowFocus( true ); |
79 | 80 | ||
80 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 81 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
81 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 82 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
82 | 83 | ||
83 | #ifdef QWS | 84 | #ifdef QWS |
84 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 85 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
85 | #endif | 86 | #endif |
86 | 87 | ||
87 | }; | 88 | }; |
88 | 89 | ||
89 | 90 | ||
90 | MScanListView::~MScanListView() | 91 | MScanListView::~MScanListView() |
91 | { | 92 | { |
92 | }; | 93 | }; |
93 | 94 | ||
94 | 95 | ||
95 | OListViewItem* MScanListView::childFactory() | 96 | OListViewItem* MScanListView::childFactory() |
96 | { | 97 | { |
97 | return new MScanListItem( this ); | 98 | return new MScanListItem( this ); |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
101 | void MScanListView::serializeTo( QDataStream& s) const | 102 | void MScanListView::serializeTo( QDataStream& s) const |
102 | { | 103 | { |
103 | qDebug( "serializing MScanListView" ); | 104 | qDebug( "serializing MScanListView" ); |
104 | OListView::serializeTo( s ); | 105 | OListView::serializeTo( s ); |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | void MScanListView::serializeFrom( QDataStream& s) | 109 | void MScanListView::serializeFrom( QDataStream& s) |
109 | { | 110 | { |
110 | qDebug( "serializing MScanListView" ); | 111 | qDebug( "serializing MScanListView" ); |
111 | OListView::serializeFrom( s ); | 112 | OListView::serializeFrom( s ); |
112 | } | 113 | } |
113 | 114 | ||
114 | 115 | ||
115 | void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) | 116 | void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) |
116 | { | 117 | { |
117 | QString macaddr = mac.toString(true); | 118 | QString macaddr = mac.toString(true); |
118 | 119 | ||
119 | #ifdef DEBUG | 120 | #ifdef DEBUG |
120 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 121 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
121 | (const char*) essid, (const char*) macaddr, channel ); | 122 | (const char*) essid, (const char*) macaddr, channel ); |
122 | #endif | 123 | #endif |
123 | 124 | ||
124 | // search, if we already have seen this net | 125 | // search, if we already have seen this net |
125 | 126 | ||
126 | QString s; | 127 | QString s; |
127 | MScanListItem* network; | 128 | MScanListItem* network; |
128 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 129 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
129 | 130 | ||
130 | while ( item && ( item->text( col_essid ) != essid ) ) | 131 | while ( item && ( item->text( col_essid ) != essid ) ) |
131 | { | 132 | { |
132 | #ifdef DEBUG | 133 | #ifdef DEBUG |
133 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 134 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
134 | #endif | 135 | #endif |
135 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 136 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
136 | } | 137 | } |
137 | if ( item ) | 138 | if ( item ) |
138 | { | 139 | { |
139 | // we have already seen this net, check all childs if MAC exists | 140 | // we have already seen this net, check all childs if MAC exists |
140 | 141 | ||
141 | network = item; | 142 | network = item; |
142 | 143 | ||
143 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 144 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
144 | assert( item ); // this shouldn't fail | 145 | assert( item ); // this shouldn't fail |
145 | 146 | ||
146 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 147 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
147 | { | 148 | { |
148 | #ifdef DEBUG | 149 | #ifdef DEBUG |
149 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 150 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
150 | #endif | 151 | #endif |
151 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 152 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
152 | } | 153 | } |
153 | 154 | ||
154 | if ( item ) | 155 | if ( item ) |
155 | { | 156 | { |
156 | // we have already seen this item, it's a dupe | 157 | // we have already seen this item, it's a dupe |
157 | #ifdef DEBUG | 158 | #ifdef DEBUG |
158 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 159 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
159 | #endif | 160 | #endif |
160 | item->receivedBeacon(); | 161 | item->receivedBeacon(); |
161 | return; | 162 | return; |
162 | } | 163 | } |
163 | } | 164 | } |
164 | else | 165 | else |
165 | { | 166 | { |
166 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 167 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
167 | MLogWindow::logwindow()->log( s ); | 168 | MLogWindow::logwindow()->log( s ); |
168 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 169 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
169 | } | 170 | } |
170 | 171 | ||
171 | 172 | ||
172 | // insert new station as child from network | 173 | // insert new station as child from network |
173 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 174 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
174 | 175 | ||
175 | #ifdef DEBUG | 176 | #ifdef DEBUG |
176 | qDebug( "inserting new station %s", (const char*) macaddr ); | 177 | qDebug( "inserting new station %s", (const char*) macaddr ); |
177 | #endif | 178 | #endif |
178 | 179 | ||
179 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 180 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
180 | station->setManufacturer( mac.manufacturer() ); | 181 | station->setManufacturer( mac.manufacturer() ); |
181 | 182 | ||
182 | if ( type == "managed" ) | 183 | if ( type == "managed" ) |
183 | { | 184 | { |
184 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 185 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
185 | } | 186 | } |
186 | else | 187 | else |
187 | { | 188 | { |
188 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 189 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
189 | } | 190 | } |
190 | MLogWindow::logwindow()->log( s ); | 191 | MLogWindow::logwindow()->log( s ); |
191 | 192 | ||
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||
195 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 196 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
196 | { | 197 | { |
197 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 198 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
198 | 199 | ||
199 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 200 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
200 | { | 201 | { |
201 | #ifdef DEBUG | 202 | #ifdef DEBUG |
202 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 203 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
203 | #endif | 204 | #endif |
204 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 205 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
205 | } | 206 | } |
206 | 207 | ||
207 | if ( subitem ) | 208 | if ( subitem ) |
208 | { | 209 | { |
209 | // we have already seen this item, it's a dupe | 210 | // we have already seen this item, it's a dupe |
210 | #ifdef DEBUG | 211 | #ifdef DEBUG |
211 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 212 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
212 | #endif | 213 | #endif |
213 | subitem->receivedBeacon(); //FIXME: sent data bit | 214 | subitem->receivedBeacon(); //FIXME: sent data bit |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | 217 | ||
217 | // Hey, it seems to be a new item :-D | 218 | // Hey, it seems to be a new item :-D |
218 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 219 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
219 | station->setManufacturer( addr.manufacturer() ); | 220 | station->setManufacturer( addr.manufacturer() ); |
220 | 221 | ||
221 | QString s; | 222 | QString s; |
222 | if ( type == "station" ) | 223 | if ( type == "station" ) |
223 | { | 224 | { |
224 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 225 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
225 | } | 226 | } |
226 | else | 227 | else |
227 | { | 228 | { |
228 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 229 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
229 | } | 230 | } |
230 | MLogWindow::logwindow()->log( s ); | 231 | MLogWindow::logwindow()->log( s ); |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
234 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 235 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
235 | { | 236 | { |
236 | QString s; | 237 | QString s; |
237 | MScanListItem* network; | 238 | MScanListItem* network; |
238 | 239 | ||
239 | QListViewItemIterator it( this ); | 240 | QListViewItemIterator it( this ); |
240 | while ( it.current() && | 241 | while ( it.current() && |
241 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 242 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
242 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 243 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
243 | 244 | ||
244 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 245 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
245 | 246 | ||
246 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 247 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
247 | { | 248 | { |
248 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 249 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
249 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 250 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
250 | } | 251 | } |
251 | else | 252 | else |
252 | { | 253 | { |
253 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 254 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
254 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 255 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
255 | } | 256 | } |
256 | } | 257 | } |
257 | 258 | ||
258 | 259 | ||
259 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 260 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
260 | { | 261 | { |
261 | QString s; | 262 | QString s; |
262 | MScanListItem* network; | 263 | MScanListItem* network; |
263 | 264 | ||
264 | QListViewItemIterator it( this ); | 265 | QListViewItemIterator it( this ); |
265 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 266 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
266 | 267 | ||
267 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 268 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
268 | 269 | ||
269 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 270 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
270 | { | 271 | { |
271 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 272 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
272 | } | 273 | } |
273 | else | 274 | else |
274 | { | 275 | { |
275 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 276 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
276 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 277 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index dcf796f..96733ff 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -221,310 +221,317 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) | |||
221 | { | 221 | { |
222 | qDebug( "Received IP packet." ); | 222 | qDebug( "Received IP packet." ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 227 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
228 | { | 228 | { |
229 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 229 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
230 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 230 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
231 | return 0; | 231 | return 0; |
232 | 232 | ||
233 | return p->child( protocol ); | 233 | return p->child( protocol ); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 237 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
238 | { | 238 | { |
239 | // go through all child packets and see if one is inside the child hierarchy for p | 239 | // go through all child packets and see if one is inside the child hierarchy for p |
240 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 240 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
241 | if ( !configwindow->writeCaptureFile->isOn() ) | 241 | if ( !configwindow->writeCaptureFile->isOn() ) |
242 | return false; | 242 | return false; |
243 | 243 | ||
244 | QObjectList* l = p->queryList(); | 244 | QObjectList* l = p->queryList(); |
245 | QObjectListIt it( *l ); | 245 | QObjectListIt it( *l ); |
246 | QObject* o; | 246 | QObject* o; |
247 | 247 | ||
248 | while ( (o = it.current()) != 0 ) | 248 | while ( (o = it.current()) != 0 ) |
249 | { | 249 | { |
250 | QString name = it.current()->name(); | 250 | QString name = it.current()->name(); |
251 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 251 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
252 | { | 252 | { |
253 | QString action = configwindow->capturePackets->protocolAction( name ); | 253 | QString action = configwindow->capturePackets->protocolAction( name ); |
254 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 254 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
255 | if ( action == "Discard" ) | 255 | if ( action == "Discard" ) |
256 | { | 256 | { |
257 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 257 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 263 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
264 | } | 264 | } |
265 | ++it; | 265 | ++it; |
266 | } | 266 | } |
267 | return true; | 267 | return true; |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void Wellenreiter::receivePacket( OPacket* p ) | 271 | void Wellenreiter::receivePacket( OPacket* p ) |
272 | { | 272 | { |
273 | hexWindow()->log( p->dump( 8 ) ); | 273 | hexWindow()->log( p->dump( 8 ) ); |
274 | 274 | ||
275 | if ( checkDumpPacket( p ) ) | 275 | if ( checkDumpPacket( p ) ) |
276 | { | 276 | { |
277 | pcap->dump( p ); | 277 | pcap->dump( p ); |
278 | } | 278 | } |
279 | 279 | ||
280 | // check if we received a beacon frame | 280 | // check if we received a beacon frame |
281 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 281 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
282 | if ( beacon && beacon->managementType() == "Beacon" ) | 282 | if ( beacon && beacon->managementType() == "Beacon" ) |
283 | { | 283 | { |
284 | handleBeacon( p, beacon ); | 284 | handleBeacon( p, beacon ); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | 287 | ||
288 | //TODO: WEP check here | 288 | //TODO: WEP check here |
289 | 289 | ||
290 | // check for a data frame | 290 | // check for a data frame |
291 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 291 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
292 | if ( data ) | 292 | if ( data ) |
293 | { | 293 | { |
294 | handleData( p, data ); | 294 | handleData( p, data ); |
295 | } | 295 | } |
296 | 296 | ||
297 | handleNotification( p ); | 297 | handleNotification( p ); |
298 | 298 | ||
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void Wellenreiter::stopClicked() | 302 | void Wellenreiter::stopClicked() |
303 | { | 303 | { |
304 | if ( iface ) | 304 | if ( iface ) |
305 | { | 305 | { |
306 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 306 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
307 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 307 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
308 | iface->setChannelHopping(); // stop hopping channels | 308 | iface->setChannelHopping(); // stop hopping channels |
309 | } | 309 | } |
310 | else | 310 | else |
311 | killTimers(); | 311 | killTimers(); |
312 | 312 | ||
313 | pcap->close(); | 313 | pcap->close(); |
314 | sniffing = false; | 314 | sniffing = false; |
315 | 315 | ||
316 | if ( iface ) | 316 | if ( iface ) |
317 | { | 317 | { |
318 | // switch off monitor mode | 318 | // switch off monitor mode |
319 | iface->setMonitorMode( false ); | 319 | iface->setMonitorMode( false ); |
320 | // switch off promisc flag | 320 | // switch off promisc flag |
321 | iface->setPromiscuousMode( false ); | 321 | iface->setPromiscuousMode( false ); |
322 | 322 | ||
323 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 323 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
324 | } | 324 | } |
325 | 325 | ||
326 | logwindow->log( "(i) Stopped Scanning." ); | 326 | logwindow->log( "(i) Stopped Scanning." ); |
327 | assert( parent() ); | 327 | assert( parent() ); |
328 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 328 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
329 | 329 | ||
330 | // message the user | 330 | // message the user |
331 | QMessageBox::information( this, "Wellenreiter II", | 331 | QMessageBox::information( this, "Wellenreiter II", |
332 | tr( "Your wireless card\nshould now be usable again." ) ); | 332 | tr( "Your wireless card\nshould now be usable again." ) ); |
333 | 333 | ||
334 | sniffing = false; | 334 | sniffing = false; |
335 | emit( stoppedSniffing() ); | 335 | emit( stoppedSniffing() ); |
336 | 336 | ||
337 | // print out statistics | 337 | // print out statistics |
338 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 338 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
339 | statwindow->updateCounter( it.key(), it.data() ); | 339 | statwindow->updateCounter( it.key(), it.data() ); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void Wellenreiter::startClicked() | 343 | void Wellenreiter::startClicked() |
344 | { | 344 | { |
345 | // get configuration from config window | 345 | // get configuration from config window |
346 | 346 | ||
347 | const QString& interface = configwindow->interfaceName->currentText(); | 347 | const QString& interface = configwindow->interfaceName->currentText(); |
348 | const int cardtype = configwindow->driverType(); | 348 | const int cardtype = configwindow->driverType(); |
349 | const int interval = configwindow->hoppingInterval(); | 349 | const int interval = configwindow->hoppingInterval(); |
350 | 350 | ||
351 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 351 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
352 | { | 352 | { |
353 | QMessageBox::information( this, "Wellenreiter II", | 353 | QMessageBox::information( this, "Wellenreiter II", |
354 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 354 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
355 | return; | 355 | return; |
356 | } | 356 | } |
357 | 357 | ||
358 | // configure device | 358 | // configure device |
359 | ONetwork* net = ONetwork::instance(); | 359 | ONetwork* net = ONetwork::instance(); |
360 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 360 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
361 | 361 | ||
362 | // bring device UP | 362 | // bring device UP |
363 | iface->setUp( true ); | 363 | iface->setUp( true ); |
364 | if ( !iface->isUp() ) | 364 | if ( !iface->isUp() ) |
365 | { | 365 | { |
366 | QMessageBox::warning( this, "Wellenreiter II", | 366 | QMessageBox::warning( this, "Wellenreiter II", |
367 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 367 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
368 | return; | 368 | return; |
369 | } | 369 | } |
370 | 370 | ||
371 | // set monitor mode | 371 | // set monitor mode |
372 | bool usePrism = configwindow->usePrismHeader(); | 372 | bool usePrism = configwindow->usePrismHeader(); |
373 | 373 | ||
374 | switch ( cardtype ) | 374 | switch ( cardtype ) |
375 | { | 375 | { |
376 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 376 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
377 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 377 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
378 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 378 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
379 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 379 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
380 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 380 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
381 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 381 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
382 | default: assert( 0 ); // shouldn't reach this | 382 | default: assert( 0 ); // shouldn't reach this |
383 | } | 383 | } |
384 | 384 | ||
385 | // switch device into monitor mode | 385 | // switch device into monitor mode |
386 | if ( cardtype < DEVTYPE_FILE ) | 386 | if ( cardtype < DEVTYPE_FILE ) |
387 | { | 387 | { |
388 | if ( cardtype != DEVTYPE_MANUAL ) | 388 | if ( cardtype != DEVTYPE_MANUAL ) |
389 | iface->setMonitorMode( true ); | 389 | iface->setMonitorMode( true ); |
390 | if ( !iface->monitorMode() ) | 390 | if ( !iface->monitorMode() ) |
391 | { | 391 | { |
392 | QMessageBox::warning( this, "Wellenreiter II", | 392 | QMessageBox::warning( this, "Wellenreiter II", |
393 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); | 393 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // open pcap and start sniffing | 398 | // open pcap and start sniffing |
399 | if ( cardtype != DEVTYPE_FILE ) | 399 | if ( cardtype != DEVTYPE_FILE ) |
400 | { | 400 | { |
401 | pcap->open( interface ); | 401 | pcap->open( interface ); |
402 | 402 | ||
403 | if ( configwindow->writeCaptureFile->isOn() ) | 403 | if ( configwindow->writeCaptureFile->isOn() ) |
404 | { | 404 | { |
405 | QString dumpname( configwindow->captureFileName->text() ); | 405 | QString dumpname( configwindow->captureFileName->text() ); |
406 | dumpname.append( '-' ); | 406 | dumpname.append( '-' ); |
407 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 407 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
408 | dumpname.append( ".wellenreiter" ); | 408 | dumpname.append( ".wellenreiter" ); |
409 | pcap->openDumpFile( dumpname ); | 409 | pcap->openDumpFile( dumpname ); |
410 | } | 410 | } |
411 | else | 411 | else |
412 | { | 412 | { |
413 | pcap->open( interface ); | 413 | pcap->open( interface ); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | else | 416 | else |
417 | { | 417 | { |
418 | pcap->open( QFile( interface ) ); | 418 | pcap->open( QFile( interface ) ); |
419 | } | 419 | } |
420 | 420 | ||
421 | if ( !pcap->isOpen() ) | 421 | if ( !pcap->isOpen() ) |
422 | { | 422 | { |
423 | QMessageBox::warning( this, "Wellenreiter II", | 423 | QMessageBox::warning( this, "Wellenreiter II", |
424 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); | 424 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
428 | // set capturer to non-blocking mode | 428 | // set capturer to non-blocking mode |
429 | pcap->setBlocking( false ); | 429 | pcap->setBlocking( false ); |
430 | 430 | ||
431 | // start channel hopper | 431 | // start channel hopper |
432 | if ( cardtype != DEVTYPE_FILE ) | 432 | if ( cardtype != DEVTYPE_FILE ) |
433 | iface->setChannelHopping( 1000 ); //use interval from config window | 433 | iface->setChannelHopping( 1000 ); //use interval from config window |
434 | 434 | ||
435 | if ( cardtype != DEVTYPE_FILE ) | 435 | if ( cardtype != DEVTYPE_FILE ) |
436 | { | 436 | { |
437 | // connect socket notifier and start channel hopper | 437 | // connect socket notifier and start channel hopper |
438 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 438 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
439 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 439 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | // start timer for reading packets | 443 | // start timer for reading packets |
444 | startTimer( 100 ); | 444 | startTimer( 100 ); |
445 | } | 445 | } |
446 | 446 | ||
447 | logwindow->log( "(i) Started Scanning." ); | 447 | logwindow->log( "(i) Started Scanning." ); |
448 | sniffing = true; | 448 | sniffing = true; |
449 | emit( startedSniffing() ); | 449 | emit( startedSniffing() ); |
450 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 450 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
451 | else | 451 | else |
452 | { | 452 | { |
453 | assert( parent() ); | 453 | assert( parent() ); |
454 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 454 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void Wellenreiter::timerEvent( QTimerEvent* ) | 459 | void Wellenreiter::timerEvent( QTimerEvent* ) |
460 | { | 460 | { |
461 | qDebug( "Wellenreiter::timerEvent()" ); | 461 | qDebug( "Wellenreiter::timerEvent()" ); |
462 | OPacket* p = pcap->next(); | 462 | OPacket* p = pcap->next(); |
463 | if ( !p ) // no more packets available | 463 | if ( !p ) // no more packets available |
464 | { | 464 | { |
465 | stopClicked(); | 465 | stopClicked(); |
466 | } | 466 | } |
467 | else | 467 | else |
468 | { | 468 | { |
469 | receivePacket( p ); | 469 | receivePacket( p ); |
470 | delete p; | 470 | delete p; |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 475 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
476 | { | 476 | { |
477 | #ifdef QWS | ||
477 | if ( action == "TouchSound" ) | 478 | if ( action == "TouchSound" ) |
478 | ODevice::inst()->touchSound(); | 479 | ODevice::inst()->touchSound(); |
479 | else if ( action == "AlarmSound" ) | 480 | else if ( action == "AlarmSound" ) |
480 | ODevice::inst()->alarmSound(); | 481 | ODevice::inst()->alarmSound(); |
481 | else if ( action == "KeySound" ) | 482 | else if ( action == "KeySound" ) |
482 | ODevice::inst()->keySound(); | 483 | ODevice::inst()->keySound(); |
483 | else if ( action == "LedOn" ) | 484 | else if ( action == "LedOn" ) |
484 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 485 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
485 | else if ( action == "LedOff" ) | 486 | else if ( action == "LedOff" ) |
486 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 487 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
487 | else if ( action == "LogMessage" ) | 488 | else if ( action == "LogMessage" ) |
488 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 489 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
489 | else if ( action == "MessageBox" ) | 490 | else if ( action == "MessageBox" ) |
490 | QMessageBox::information( this, "Notification!", | 491 | QMessageBox::information( this, "Notification!", |
491 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 492 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
493 | #else | ||
494 | #warning Actions do not work with Qt/X11 yet | ||
495 | #endif | ||
492 | } | 496 | } |
493 | 497 | ||
494 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 498 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
495 | { | 499 | { |
500 | #ifdef QWS | ||
496 | if ( !iface ) | 501 | if ( !iface ) |
497 | { | 502 | { |
498 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 503 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
499 | return; | 504 | return; |
500 | } | 505 | } |
501 | 506 | ||
502 | if ( sniffing ) | 507 | if ( sniffing ) |
503 | { | 508 | { |
504 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 509 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
505 | return; | 510 | return; |
506 | } | 511 | } |
507 | 512 | ||
508 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 513 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
509 | (const char*) iface->name(), | 514 | (const char*) iface->name(), |
510 | (const char*) type, | 515 | (const char*) type, |
511 | (const char*) essid, | 516 | (const char*) essid, |
512 | channel, | 517 | channel, |
513 | (const char*) macaddr ); | 518 | (const char*) macaddr ); |
514 | 519 | ||
515 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 520 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
516 | int count = 3; | 521 | int count = 3; |
517 | qDebug("sending %d messages",count); | 522 | qDebug("sending %d messages",count); |
518 | msg << QString("count") << QString::number(count); | 523 | msg << QString("count") << QString::number(count); |
519 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 524 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); |
520 | msg << QString(iface->name()) << QString("Mode") << type; | 525 | msg << QString(iface->name()) << QString("Mode") << type; |
521 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 526 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); |
522 | msg << QString(iface->name()) << QString("ESSID") << essid; | 527 | msg << QString(iface->name()) << QString("ESSID") << essid; |
523 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 528 | qDebug("msg >%s< channel >%d<", iface->name(),channel); |
524 | msg << QString(iface->name()) << QString("Channel") << channel; | 529 | msg << QString(iface->name()) << QString("Channel") << channel; |
525 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 530 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
526 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 531 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
527 | 532 | #else | |
533 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | ||
534 | #endif | ||
528 | 535 | ||
529 | } | 536 | } |
530 | 537 | ||