summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp6
-rw-r--r--libopie2/opienet/onetwork.cpp3
-rw-r--r--libopie2/opienet/onetwork.h8
3 files changed, 13 insertions, 4 deletions
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 184ee69..1799529 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -1,547 +1,547 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the KDE globalsettings which are 5 Inspired by the KDE globalsettings which are
6 Copyright (C) 2000 David Faure <faure@kde.org> 6 Copyright (C) 2000 David Faure <faure@kde.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33/* OPIE */ 33/* OPIE */
34 34
35#include <opie2/oglobalsettings.h> 35#include <opie2/oglobalsettings.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oglobal.h> 37#include <opie2/oglobal.h>
38 38
39/* QT */ 39/* QT */
40 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qfontinfo.h> 43#include <qfontinfo.h>
44 44
45/* UNIX */ 45/* UNIX */
46 46
47#include <stdlib.h> 47#include <stdlib.h>
48 48
49QString* OGlobalSettings::s_desktopPath = 0; 49QString* OGlobalSettings::s_desktopPath = 0;
50QString* OGlobalSettings::s_autostartPath = 0; 50QString* OGlobalSettings::s_autostartPath = 0;
51QString* OGlobalSettings::s_trashPath = 0; 51QString* OGlobalSettings::s_trashPath = 0;
52QString* OGlobalSettings::s_documentPath = 0; 52QString* OGlobalSettings::s_documentPath = 0;
53QFont *OGlobalSettings::_generalFont = 0; 53QFont *OGlobalSettings::_generalFont = 0;
54QFont *OGlobalSettings::_fixedFont = 0; 54QFont *OGlobalSettings::_fixedFont = 0;
55QFont *OGlobalSettings::_toolBarFont = 0; 55QFont *OGlobalSettings::_toolBarFont = 0;
56QFont *OGlobalSettings::_menuFont = 0; 56QFont *OGlobalSettings::_menuFont = 0;
57QFont *OGlobalSettings::_windowTitleFont = 0; 57QFont *OGlobalSettings::_windowTitleFont = 0;
58QFont *OGlobalSettings::_taskbarFont = 0; 58QFont *OGlobalSettings::_taskbarFont = 0;
59 59
60QColor *OGlobalSettings::OpieGray = 0; 60QColor *OGlobalSettings::OpieGray = 0;
61QColor *OGlobalSettings::OpieHighlight = 0; 61QColor *OGlobalSettings::OpieHighlight = 0;
62QColor *OGlobalSettings::OpieAlternate = 0; 62QColor *OGlobalSettings::OpieAlternate = 0;
63 63
64OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; 64OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
65 65
66//FIXME: Add manipulators to the accessors 66//FIXME: Add manipulators to the accessors
67 67
68int OGlobalSettings::dndEventDelay() 68int OGlobalSettings::dndEventDelay()
69{ 69{
70 OConfig *c = OGlobal::config(); 70 OConfig *c = OGlobal::config();
71 OConfigGroupSaver cgs( c, "General" ); 71 OConfigGroupSaver cgs( c, "General" );
72 return c->readNumEntry("DndDelay", 2); 72 return c->readNumEntry("DndDelay", 2);
73} 73}
74 74
75bool OGlobalSettings::singleClick() 75bool OGlobalSettings::singleClick()
76{ 76{
77 OConfig *c = OGlobal::config(); 77 OConfig *c = OGlobal::config();
78 OConfigGroupSaver cgs( c, "OPIE" ); 78 OConfigGroupSaver cgs( c, "OPIE" );
79 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); 79 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
80} 80}
81 81
82bool OGlobalSettings::insertTearOffHandle() 82bool OGlobalSettings::insertTearOffHandle()
83{ 83{
84 OConfig *c = OGlobal::config(); 84 OConfig *c = OGlobal::config();
85 OConfigGroupSaver cgs( c, "OPIE" ); 85 OConfigGroupSaver cgs( c, "OPIE" );
86 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); 86 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
87} 87}
88 88
89bool OGlobalSettings::changeCursorOverIcon() 89bool OGlobalSettings::changeCursorOverIcon()
90{ 90{
91 OConfig *c = OGlobal::config(); 91 OConfig *c = OGlobal::config();
92 OConfigGroupSaver cgs( c, "OPIE" ); 92 OConfigGroupSaver cgs( c, "OPIE" );
93 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); 93 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
94} 94}
95 95
96bool OGlobalSettings::visualActivate() 96bool OGlobalSettings::visualActivate()
97{ 97{
98 OConfig *c = OGlobal::config(); 98 OConfig *c = OGlobal::config();
99 OConfigGroupSaver cgs( c, "OPIE" ); 99 OConfigGroupSaver cgs( c, "OPIE" );
100 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); 100 return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE);
101} 101}
102 102
103unsigned int OGlobalSettings::visualActivateSpeed() 103unsigned int OGlobalSettings::visualActivateSpeed()
104{ 104{
105 OConfig *c = OGlobal::config(); 105 OConfig *c = OGlobal::config();
106 OConfigGroupSaver cgs( c, "OPIE" ); 106 OConfigGroupSaver cgs( c, "OPIE" );
107 return 107 return
108 c->readNumEntry( 108 c->readNumEntry(
109 "VisualActivateSpeed", 109 "VisualActivateSpeed",
110 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 110 OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED
111 ); 111 );
112} 112}
113 113
114int OGlobalSettings::autoSelectDelay() 114int OGlobalSettings::autoSelectDelay()
115{ 115{
116 OConfig *c = OGlobal::config(); 116 OConfig *c = OGlobal::config();
117 OConfigGroupSaver cgs( c, "OPIE" ); 117 OConfigGroupSaver cgs( c, "OPIE" );
118 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); 118 return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY);
119} 119}
120 120
121OGlobalSettings::Completion OGlobalSettings::completionMode() 121OGlobalSettings::Completion OGlobalSettings::completionMode()
122{ 122{
123 int completion; 123 int completion;
124 OConfig *c = OGlobal::config(); 124 OConfig *c = OGlobal::config();
125 OConfigGroupSaver cgs( c, "General" ); 125 OConfigGroupSaver cgs( c, "General" );
126 completion = c->readNumEntry("completionMode", -1); 126 completion = c->readNumEntry("completionMode", -1);
127 if ((completion < (int) CompletionNone) || 127 if ((completion < (int) CompletionNone) ||
128 (completion > (int) CompletionPopupAuto)) 128 (completion > (int) CompletionPopupAuto))
129 { 129 {
130 completion = (int) CompletionPopup; // Default 130 completion = (int) CompletionPopup; // Default
131 } 131 }
132 return (Completion) completion; 132 return (Completion) completion;
133} 133}
134 134
135 135
136bool OGlobalSettings::showContextMenusOnPress () 136bool OGlobalSettings::showContextMenusOnPress ()
137{ 137{
138 OConfig *c = OGlobal::config(); 138 OConfig *c = OGlobal::config();
139 OConfigGroupSaver cgs (c, "ContextMenus"); 139 OConfigGroupSaver cgs (c, "ContextMenus");
140 140
141 return cgs.config()->readBoolEntry("ShowOnPress", true); 141 return cgs.config()->readBoolEntry("ShowOnPress", true);
142} 142}
143 143
144 144
145int OGlobalSettings::contextMenuKey () 145int OGlobalSettings::contextMenuKey ()
146{ 146{
147 OConfig *c = OGlobal::config(); 147 OConfig *c = OGlobal::config();
148 OConfigGroupSaver cgs (c, "Shortcuts"); 148 OConfigGroupSaver cgs (c, "Shortcuts");
149 149
150 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); 150 //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu"));
151 //return cut.keyCodeQt(); 151 //return cut.keyCodeQt();
152 152
153 return 0; // FIXME 153 return 0; // FIXME
154} 154}
155 155
156 156
157OGlobalSettings::Debug OGlobalSettings::debugMode() 157OGlobalSettings::Debug OGlobalSettings::debugMode()
158{ 158{
159 OConfig *c = OGlobal::config(); 159 OConfig *c = OGlobal::config();
160 OConfigGroupSaver cgs( c, "General" ); 160 OConfigGroupSaver cgs( c, "General" );
161 int debug = c->readNumEntry( "debugMode", -1 ); 161 int debug = c->readNumEntry( "debugMode", -1 );
162 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) 162 if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) )
163 { 163 {
164 debug = (int) DebugStdErr; // Default 164 debug = (int) DebugStdErr; // Default
165 } 165 }
166 return (Debug) debug; 166 return (Debug) debug;
167} 167}
168 168
169 169
170QString OGlobalSettings::debugOutput() 170QString OGlobalSettings::debugOutput()
171{ 171{
172 OConfig *c = OGlobal::config(); 172 OConfig *c = OGlobal::config();
173 OConfigGroupSaver cgs( c, "General" ); 173 OConfigGroupSaver cgs( c, "General" );
174 QString deflt = QString::null; 174 QString deflt = QString::null;
175 switch( debugMode() ) 175 switch( debugMode() )
176 { 176 {
177 case DebugNone: break; // no additional information needed 177 case DebugNone: break; // no additional information needed
178 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in 178 case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in
179 case DebugMsgBox: break; // no additional information needed 179 case DebugMsgBox: break; // no additional information needed
180 case DebugStdErr: break; // no additional information needed 180 case DebugStdErr: break; // no additional information needed
181 case DebugSysLog: break; // no additional information needed 181 case DebugSysLog: break; // no additional information needed
182 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to 182 case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to
183 } 183 }
184 184
185 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); 185 return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt );
186} 186}
187 187
188 188
189QColor OGlobalSettings::toolBarHighlightColor() 189QColor OGlobalSettings::toolBarHighlightColor()
190{ 190{
191 initColors(); 191 initColors();
192 OConfig *c = OGlobal::config(); 192 OConfig *c = OGlobal::config();
193 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); 193 OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") );
194 return c->readColorEntry("HighlightColor", OpieHighlight); 194 return c->readColorEntry("HighlightColor", OpieHighlight);
195} 195}
196 196
197QColor OGlobalSettings::inactiveTitleColor() 197QColor OGlobalSettings::inactiveTitleColor()
198{ 198{
199 if (!OpieGray) OpieGray = new QColor(220, 220, 220); 199 if (!OpieGray) OpieGray = new QColor(220, 220, 220);
200 OConfig *c = OGlobal::config(); 200 OConfig *c = OGlobal::config();
201 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 201 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
202 return c->readColorEntry( "inactiveBackground", OpieGray ); 202 return c->readColorEntry( "inactiveBackground", OpieGray );
203} 203}
204 204
205QColor OGlobalSettings::inactiveTextColor() 205QColor OGlobalSettings::inactiveTextColor()
206{ 206{
207 OConfig *c = OGlobal::config(); 207 OConfig *c = OGlobal::config();
208 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 208 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
209 return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); 209 return c->readColorEntry( "inactiveForeground", &Qt::darkGray );
210} 210}
211 211
212QColor OGlobalSettings::activeTitleColor() 212QColor OGlobalSettings::activeTitleColor()
213{ 213{
214 initColors(); 214 initColors();
215 OConfig *c = OGlobal::config(); 215 OConfig *c = OGlobal::config();
216 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 216 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
217 return c->readColorEntry( "activeBackground", OpieHighlight); 217 return c->readColorEntry( "activeBackground", OpieHighlight);
218} 218}
219 219
220QColor OGlobalSettings::activeTextColor() 220QColor OGlobalSettings::activeTextColor()
221{ 221{
222 OConfig *c = OGlobal::config(); 222 OConfig *c = OGlobal::config();
223 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 223 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
224 return c->readColorEntry( "activeForeground", &Qt::white ); 224 return c->readColorEntry( "activeForeground", &Qt::white );
225} 225}
226 226
227int OGlobalSettings::contrast() 227int OGlobalSettings::contrast()
228{ 228{
229 OConfig *c = OGlobal::config(); 229 OConfig *c = OGlobal::config();
230 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); 230 OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") );
231 return c->readNumEntry( "contrast", 7 ); 231 return c->readNumEntry( "contrast", 7 );
232} 232}
233 233
234// following functions should work in OPIE - how to sync with appearance changes? 234// following functions should work in OPIE - how to sync with appearance changes?
235 235
236QColor OGlobalSettings::baseColor() 236QColor OGlobalSettings::baseColor()
237{ 237{
238 OConfig *c = OGlobal::config(); 238 OConfig *c = OGlobal::config();
239 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 239 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
240 return c->readColorEntry( "Base", &Qt::white ); 240 return c->readColorEntry( "Base", &Qt::white );
241} 241}
242 242
243QColor OGlobalSettings::textColor() 243QColor OGlobalSettings::textColor()
244{ 244{
245 OConfig *c = OGlobal::config(); 245 OConfig *c = OGlobal::config();
246 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 246 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
247 return c->readColorEntry( "Text", &Qt::black ); 247 return c->readColorEntry( "Text", &Qt::black );
248} 248}
249 249
250QColor OGlobalSettings::highlightedTextColor() 250QColor OGlobalSettings::highlightedTextColor()
251{ 251{
252 OConfig *c = OGlobal::config(); 252 OConfig *c = OGlobal::config();
253 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 253 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
254 return c->readColorEntry( "HighlightedText", &Qt::white ); 254 return c->readColorEntry( "HighlightedText", &Qt::white );
255} 255}
256 256
257QColor OGlobalSettings::highlightColor() 257QColor OGlobalSettings::highlightColor()
258{ 258{
259 initColors(); 259 initColors();
260 OConfig *c = OGlobal::config(); 260 OConfig *c = OGlobal::config();
261 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 261 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
262 return c->readColorEntry( "Highlight", OpieHighlight ); 262 return c->readColorEntry( "Highlight", OpieHighlight );
263} 263}
264 264
265QColor OGlobalSettings::alternateBackgroundColor() 265QColor OGlobalSettings::alternateBackgroundColor()
266{ 266{
267 initColors(); 267 initColors();
268 OConfig *c = OGlobal::config(); 268 OConfig *c = OGlobal::config();
269 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 269 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
270 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); 270 *OpieAlternate = calculateAlternateBackgroundColor( baseColor() );
271 return c->readColorEntry( "alternateBackground", OpieAlternate ); 271 return c->readColorEntry( "alternateBackground", OpieAlternate );
272} 272}
273 273
274QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) 274QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base)
275{ 275{
276 if (base == Qt::white) 276 if (base == Qt::white)
277 return QColor(238,246,255); 277 return QColor(238,246,255);
278 else 278 else
279 { 279 {
280 int h, s, v; 280 int h, s, v;
281 base.hsv( &h, &s, &v ); 281 base.hsv( &h, &s, &v );
282 if (v > 128) 282 if (v > 128)
283 return base.dark(106); 283 return base.dark(106);
284 else if (base != Qt::black) 284 else if (base != Qt::black)
285 return base.light(110); 285 return base.light(110);
286 286
287 return QColor(32,32,32); 287 return QColor(32,32,32);
288 } 288 }
289} 289}
290 290
291QColor OGlobalSettings::linkColor() 291QColor OGlobalSettings::linkColor()
292{ 292{
293 initColors(); 293 initColors();
294 OConfig *c = OGlobal::config(); 294 OConfig *c = OGlobal::config();
295 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 295 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
296 return c->readColorEntry( "linkColor", OpieGray ); 296 return c->readColorEntry( "linkColor", OpieGray );
297} 297}
298 298
299QColor OGlobalSettings::visitedLinkColor() 299QColor OGlobalSettings::visitedLinkColor()
300{ 300{
301 OConfig *c = OGlobal::config(); 301 OConfig *c = OGlobal::config();
302 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 302 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
303 return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); 303 return c->readColorEntry( "visitedLinkColor", &Qt::magenta );
304} 304}
305 305
306// FIXME: font stuff currently uses a different format in OPIE, so the 306// FIXME: font stuff currently uses a different format in OPIE, so the
307// functions below are not yet applicable. The whole font stuff for OPIE 307// functions below are not yet applicable. The whole font stuff for OPIE
308// has to be revised anyway 308// has to be revised anyway
309 309
310QFont OGlobalSettings::generalFont() 310QFont OGlobalSettings::generalFont()
311{ 311{
312 if (_generalFont) 312 if (_generalFont)
313 return *_generalFont; 313 return *_generalFont;
314 314
315 _generalFont = new QFont("helvetica", 10); 315 _generalFont = new QFont("helvetica", 10);
316 _generalFont->setPixelSize(10); 316 _generalFont->setPixelSize(10);
317 _generalFont->setStyleHint(QFont::SansSerif); 317 _generalFont->setStyleHint(QFont::SansSerif);
318 318
319 OConfig *c = OGlobal::config(); 319 OConfig *c = OGlobal::config();
320 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); 320 OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") );
321 *_generalFont = c->readFontEntry("font", _generalFont); 321 *_generalFont = c->readFontEntry("font", _generalFont);
322 322
323 return *_generalFont; 323 return *_generalFont;
324} 324}
325 325
326QFont OGlobalSettings::fixedFont() 326QFont OGlobalSettings::fixedFont()
327{ 327{
328 if (_fixedFont) 328 if (_fixedFont)
329 return *_fixedFont; 329 return *_fixedFont;
330 330
331 _fixedFont = new QFont("courier", 12); 331 _fixedFont = new QFont("courier", 12);
332 _fixedFont->setPixelSize(12); 332 _fixedFont->setPixelSize(12);
333 _fixedFont->setStyleHint(QFont::TypeWriter); 333 _fixedFont->setStyleHint(QFont::TypeWriter);
334 334
335 OConfig *c = OGlobal::config(); 335 OConfig *c = OGlobal::config();
336 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 336 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
337 *_fixedFont = c->readFontEntry("fixed", _fixedFont); 337 *_fixedFont = c->readFontEntry("fixed", _fixedFont);
338 338
339 return *_fixedFont; 339 return *_fixedFont;
340} 340}
341 341
342QFont OGlobalSettings::toolBarFont() 342QFont OGlobalSettings::toolBarFont()
343{ 343{
344 if(_toolBarFont) 344 if(_toolBarFont)
345 return *_toolBarFont; 345 return *_toolBarFont;
346 346
347 _toolBarFont = new QFont("helvetica", 10); 347 _toolBarFont = new QFont("helvetica", 10);
348 _toolBarFont->setPixelSize(10); 348 _toolBarFont->setPixelSize(10);
349 _toolBarFont->setStyleHint(QFont::SansSerif); 349 _toolBarFont->setStyleHint(QFont::SansSerif);
350 350
351 OConfig *c = OGlobal::config(); 351 OConfig *c = OGlobal::config();
352 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 352 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
353 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); 353 *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont);
354 354
355 return *_toolBarFont; 355 return *_toolBarFont;
356} 356}
357 357
358QFont OGlobalSettings::menuFont() 358QFont OGlobalSettings::menuFont()
359{ 359{
360 if(_menuFont) 360 if(_menuFont)
361 return *_menuFont; 361 return *_menuFont;
362 362
363 _menuFont = new QFont("helvetica", 12); 363 _menuFont = new QFont("helvetica", 12);
364 _menuFont->setPixelSize(12); 364 _menuFont->setPixelSize(12);
365 _menuFont->setStyleHint(QFont::SansSerif); 365 _menuFont->setStyleHint(QFont::SansSerif);
366 366
367 OConfig *c = OGlobal::config(); 367 OConfig *c = OGlobal::config();
368 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 368 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
369 *_menuFont = c->readFontEntry("menuFont", _menuFont); 369 *_menuFont = c->readFontEntry("menuFont", _menuFont);
370 370
371 return *_menuFont; 371 return *_menuFont;
372} 372}
373 373
374QFont OGlobalSettings::windowTitleFont() 374QFont OGlobalSettings::windowTitleFont()
375{ 375{
376 if(_windowTitleFont) 376 if(_windowTitleFont)
377 return *_windowTitleFont; 377 return *_windowTitleFont;
378 378
379 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); 379 _windowTitleFont = new QFont("helvetica", 12, QFont::Bold);
380 _windowTitleFont->setPixelSize(12); 380 _windowTitleFont->setPixelSize(12);
381 _windowTitleFont->setStyleHint(QFont::SansSerif); 381 _windowTitleFont->setStyleHint(QFont::SansSerif);
382 382
383 OConfig *c = OGlobal::config(); 383 OConfig *c = OGlobal::config();
384 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); 384 OConfigGroupSaver cgs( c, QString::fromLatin1("WM") );
385 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency 385 *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency
386 386
387 return *_windowTitleFont; 387 return *_windowTitleFont;
388} 388}
389 389
390QFont OGlobalSettings::taskbarFont() 390QFont OGlobalSettings::taskbarFont()
391{ 391{
392 if(_taskbarFont) 392 if(_taskbarFont)
393 return *_taskbarFont; 393 return *_taskbarFont;
394 394
395 _taskbarFont = new QFont("helvetica", 8); 395 _taskbarFont = new QFont("helvetica", 8);
396 _taskbarFont->setPixelSize(8); 396 _taskbarFont->setPixelSize(8);
397 _taskbarFont->setStyleHint(QFont::SansSerif); 397 _taskbarFont->setStyleHint(QFont::SansSerif);
398 398
399 OConfig *c = OGlobal::config(); 399 OConfig *c = OGlobal::config();
400 OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); 400 OConfigGroupSaver cgs( c, QString::fromLatin1("General") );
401 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); 401 *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont);
402 402
403 return *_taskbarFont; 403 return *_taskbarFont;
404} 404}
405 405
406// FIXME: the whole path stuff has to be revised for OPIE 406// FIXME: the whole path stuff has to be revised for OPIE
407 407
408void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. 408void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here.
409{ 409{
410 if ( s_desktopPath != 0 ) 410 if ( s_desktopPath != 0 )
411 return; 411 return;
412 412
413 s_desktopPath = new QString(); 413 s_desktopPath = new QString();
414 s_autostartPath = new QString(); 414 s_autostartPath = new QString();
415 s_trashPath = new QString(); 415 s_trashPath = new QString();
416 s_documentPath = new QString(); 416 s_documentPath = new QString();
417 417
418 OConfig *config = OGlobal::config(); 418 OConfig *config = OGlobal::config();
419 //bool dollarExpansion = config->isDollarExpansion(); 419 //bool dollarExpansion = config->isDollarExpansion();
420 //config->setDollarExpansion(true); 420 //config->setDollarExpansion(true);
421 OConfigGroupSaver cgs( config, "Paths" ); 421 OConfigGroupSaver cgs( config, "Paths" );
422 422
423 // Desktop Path 423 // Desktop Path
424 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; 424 *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/";
425 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); 425 *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath);
426 if ( (*s_desktopPath)[0] != '/' ) 426 if ( (*s_desktopPath)[0] != '/' )
427 s_desktopPath->prepend( QDir::homeDirPath() + "/" ); 427 s_desktopPath->prepend( QDir::homeDirPath() + "/" );
428 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); 428 *s_desktopPath = QDir::cleanDirPath( *s_desktopPath );
429 if ( s_desktopPath->right(1) != "/") 429 if ( s_desktopPath->right(1) != "/")
430 *s_desktopPath += "/"; 430 *s_desktopPath += "/";
431 431
432 // Trash Path 432 // Trash Path
433 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; 433 *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/";
434 *s_trashPath = config->readEntry( "Trash" , *s_trashPath); 434 *s_trashPath = config->readEntry( "Trash" , *s_trashPath);
435 if ( (*s_trashPath)[0] != '/' ) 435 if ( (*s_trashPath)[0] != '/' )
436 s_trashPath->prepend( QDir::homeDirPath() + "/" ); 436 s_trashPath->prepend( QDir::homeDirPath() + "/" );
437 *s_trashPath = QDir::cleanDirPath( *s_trashPath ); 437 *s_trashPath = QDir::cleanDirPath( *s_trashPath );
438 if ( s_trashPath->right(1) != "/") 438 if ( s_trashPath->right(1) != "/")
439 *s_trashPath += "/"; 439 *s_trashPath += "/";
440 // We need to save it in any case, in case the language changes later on, 440 // We need to save it in any case, in case the language changes later on,
441 if ( !config->hasKey( "Trash" ) ) 441 if ( !config->hasKey( "Trash" ) )
442 { 442 {
443 //config->writePathEntry( "Trash", *s_trashPath, true, true ); 443 //config->writePathEntry( "Trash", *s_trashPath, true, true );
444 config->writeEntry( "Trash", *s_trashPath ); 444 config->writeEntry( "Trash", *s_trashPath );
445 //config->sync(); 445 //config->sync();
446 } 446 }
447 447
448/* // Autostart Path 448/* // Autostart Path
449 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; 449 *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/";
450 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); 450 *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath);
451 if ( (*s_autostartPath)[0] != '/' ) 451 if ( (*s_autostartPath)[0] != '/' )
452 s_autostartPath->prepend( QDir::homeDirPath() + "/" ); 452 s_autostartPath->prepend( QDir::homeDirPath() + "/" );
453 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); 453 *s_autostartPath = QDir::cleanDirPath( *s_autostartPath );
454 if ( s_autostartPath->right(1) != "/") 454 if ( s_autostartPath->right(1) != "/")
455 *s_autostartPath += "/"; 455 *s_autostartPath += "/";
456*/ 456*/
457 // Document Path 457 // Document Path
458 *s_documentPath = QString::null; 458 *s_documentPath = QString::null;
459 *s_documentPath = config->readEntry( "Documents" , *s_documentPath); 459 *s_documentPath = config->readEntry( "Documents" , *s_documentPath);
460 if ( (*s_documentPath)[0] != '/' ) 460 if ( (*s_documentPath)[0] != '/' )
461 s_documentPath->prepend( QDir::homeDirPath() + "/" ); 461 s_documentPath->prepend( QDir::homeDirPath() + "/" );
462 *s_documentPath = QDir::cleanDirPath( *s_documentPath ); 462 *s_documentPath = QDir::cleanDirPath( *s_documentPath );
463 if ( s_documentPath->right(1) != "/") 463 if ( s_documentPath->right(1) != "/")
464 *s_documentPath += "/"; 464 *s_documentPath += "/";
465 465
466 //config->setDollarExpansion(dollarExpansion); 466 //config->setDollarExpansion(dollarExpansion);
467 467
468 // Make sure this app gets the notifications about those paths 468 // Make sure this app gets the notifications about those paths
469 //if (kapp) 469 //if (kapp)
470 //kapp->addKipcEventMask(KIPC::SettingsChanged); 470 //kapp->addKipcEventMask(KIPC::SettingsChanged);
471} 471}
472 472
473void OGlobalSettings::initColors() 473void OGlobalSettings::initColors()
474{ 474{
475 if ( not OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); 475 if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 );
476 if ( not OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); 476 if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 );
477 if ( not OpieGray ) OpieGray = new QColor( 220, 210, 215 ); 477 if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 );
478} 478}
479 479
480void OGlobalSettings::rereadFontSettings() 480void OGlobalSettings::rereadFontSettings()
481{ 481{
482 delete _generalFont; 482 delete _generalFont;
483 _generalFont = 0L; 483 _generalFont = 0L;
484 delete _fixedFont; 484 delete _fixedFont;
485 _fixedFont = 0L; 485 _fixedFont = 0L;
486 delete _menuFont; 486 delete _menuFont;
487 _menuFont = 0L; 487 _menuFont = 0L;
488 delete _toolBarFont; 488 delete _toolBarFont;
489 _toolBarFont = 0L; 489 _toolBarFont = 0L;
490 delete _windowTitleFont; 490 delete _windowTitleFont;
491 _windowTitleFont = 0L; 491 _windowTitleFont = 0L;
492 delete _taskbarFont; 492 delete _taskbarFont;
493 _taskbarFont = 0L; 493 _taskbarFont = 0L;
494} 494}
495 495
496void OGlobalSettings::rereadPathSettings() 496void OGlobalSettings::rereadPathSettings()
497{ 497{
498 qDebug( "OGlobalSettings::rereadPathSettings" ); 498 qDebug( "OGlobalSettings::rereadPathSettings" );
499 delete s_autostartPath; 499 delete s_autostartPath;
500 s_autostartPath = 0L; 500 s_autostartPath = 0L;
501 delete s_trashPath; 501 delete s_trashPath;
502 s_trashPath = 0L; 502 s_trashPath = 0L;
503 delete s_desktopPath; 503 delete s_desktopPath;
504 s_desktopPath = 0L; 504 s_desktopPath = 0L;
505 delete s_documentPath; 505 delete s_documentPath;
506 s_documentPath = 0L; 506 s_documentPath = 0L;
507} 507}
508 508
509OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() 509OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings()
510{ 510{
511 if ( ! s_mouseSettings ) 511 if ( ! s_mouseSettings )
512 { 512 {
513 s_mouseSettings = new OMouseSettings; 513 s_mouseSettings = new OMouseSettings;
514 OMouseSettings & s = *s_mouseSettings; // for convenience 514 OMouseSettings & s = *s_mouseSettings; // for convenience
515 515
516 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); 516 OConfigGroupSaver cgs( OGlobal::config(), "Mouse" );
517 QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); 517 QString setting = OGlobal::config()->readEntry("MouseButtonMapping");
518 if (setting == "RightHanded") 518 if (setting == "RightHanded")
519 s.handed = OMouseSettings::RightHanded; 519 s.handed = OMouseSettings::RightHanded;
520 else if (setting == "LeftHanded") 520 else if (setting == "LeftHanded")
521 s.handed = OMouseSettings::LeftHanded; 521 s.handed = OMouseSettings::LeftHanded;
522 else 522 else
523 { 523 {
524 524
525 // FIXME: Implement for Opie / Qt Embedded 525 // FIXME: Implement for Opie / Qt Embedded
526 526
527 } 527 }
528 } 528 }
529 return *s_mouseSettings; 529 return *s_mouseSettings;
530} 530}
531 531
532void OGlobalSettings::rereadMouseSettings() 532void OGlobalSettings::rereadMouseSettings()
533{ 533{
534 delete s_mouseSettings; 534 delete s_mouseSettings;
535 s_mouseSettings = 0L; 535 s_mouseSettings = 0L;
536} 536}
537 537
538// FIXME: This won't be necessary, or will it? :-D 538// FIXME: This won't be necessary, or will it? :-D
539 539
540bool OGlobalSettings::isMultiHead() 540bool OGlobalSettings::isMultiHead()
541{ 541{
542 QCString multiHead = getenv("OPIE_MULTIHEAD"); 542 QCString multiHead = getenv("OPIE_MULTIHEAD");
543 if (!multiHead.isEmpty()) { 543 if (!multiHead.isEmpty()) {
544 return (multiHead.lower() == "true"); 544 return (multiHead.lower() == "true");
545 } 545 }
546 return false; 546 return false;
547} 547}
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 25c70e0..998b50e 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,792 +1,793 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/onetwork.h> 36#include <opie2/onetwork.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42 42
43/* UNIX */ 43/* UNIX */
44 44
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <cerrno> 46#include <cerrno>
47#include <cstring> 47#include <cstring>
48#include <cstdlib> 48#include <cstdlib>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h>
54#include <linux/wireless.h> 55#include <linux/wireless.h>
55 56
56using namespace std; 57using namespace std;
57 58
58/*====================================================================================== 59/*======================================================================================
59 * ONetwork 60 * ONetwork
60 *======================================================================================*/ 61 *======================================================================================*/
61 62
62ONetwork* ONetwork::_instance = 0; 63ONetwork* ONetwork::_instance = 0;
63 64
64ONetwork::ONetwork() 65ONetwork::ONetwork()
65{ 66{
66 qDebug( "ONetwork::ONetwork()" ); 67 qDebug( "ONetwork::ONetwork()" );
67 synchronize(); 68 synchronize();
68} 69}
69 70
70void ONetwork::synchronize() 71void ONetwork::synchronize()
71{ 72{
72 // gather available interfaces by inspecting /proc/net/dev 73 // gather available interfaces by inspecting /proc/net/dev
73 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 74 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
74 75
75 _interfaces.clear(); 76 _interfaces.clear();
76 QString str; 77 QString str;
77 QFile f( "/proc/net/dev" ); 78 QFile f( "/proc/net/dev" );
78 bool hasFile = f.open( IO_ReadOnly ); 79 bool hasFile = f.open( IO_ReadOnly );
79 if ( !hasFile ) 80 if ( !hasFile )
80 { 81 {
81 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 82 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
82 return; 83 return;
83 } 84 }
84 QTextStream s( &f ); 85 QTextStream s( &f );
85 s.readLine(); 86 s.readLine();
86 s.readLine(); 87 s.readLine();
87 while ( !s.atEnd() ) 88 while ( !s.atEnd() )
88 { 89 {
89 s >> str; 90 s >> str;
90 str.truncate( str.find( ':' ) ); 91 str.truncate( str.find( ':' ) );
91 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 92 qDebug( "ONetwork: found interface '%s'", (const char*) str );
92 ONetworkInterface* iface; 93 ONetworkInterface* iface;
93 if ( isWirelessInterface( str ) ) 94 if ( isWirelessInterface( str ) )
94 { 95 {
95 iface = new OWirelessNetworkInterface( str ); 96 iface = new OWirelessNetworkInterface( str );
96 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 97 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
97 } 98 }
98 else 99 else
99 { 100 {
100 iface = new ONetworkInterface( str ); 101 iface = new ONetworkInterface( str );
101 } 102 }
102 _interfaces.insert( str, iface ); 103 _interfaces.insert( str, iface );
103 s.readLine(); 104 s.readLine();
104 } 105 }
105} 106}
106 107
107 108
108ONetworkInterface* ONetwork::interface( QString iface ) const 109ONetworkInterface* ONetwork::interface( QString iface ) const
109{ 110{
110 return _interfaces[iface]; 111 return _interfaces[iface];
111} 112}
112 113
113 114
114ONetwork* ONetwork::instance() 115ONetwork* ONetwork::instance()
115{ 116{
116 if ( !_instance ) _instance = new ONetwork(); 117 if ( !_instance ) _instance = new ONetwork();
117 return _instance; 118 return _instance;
118} 119}
119 120
120 121
121ONetwork::InterfaceIterator ONetwork::iterator() const 122ONetwork::InterfaceIterator ONetwork::iterator() const
122{ 123{
123 return ONetwork::InterfaceIterator( _interfaces ); 124 return ONetwork::InterfaceIterator( _interfaces );
124} 125}
125 126
126 127
127bool ONetwork::isWirelessInterface( const char* name ) const 128bool ONetwork::isWirelessInterface( const char* name ) const
128{ 129{
129 int sfd = socket( AF_INET, SOCK_DGRAM, 0 ); 130 int sfd = socket( AF_INET, SOCK_DGRAM, 0 );
130 iwreqstruct iwr; 131 iwreqstruct iwr;
131 memset( &iwr, 0, sizeof( iwreqstruct ) ); 132 memset( &iwr, 0, sizeof( iwreqstruct ) );
132 strcpy( (char*) &iwr.ifr_name, name ); 133 strcpy( (char*) &iwr.ifr_name, name );
133 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 134 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
134 if ( result == -1 ) 135 if ( result == -1 )
135 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); 136 qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) );
136 else 137 else
137 qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); 138 qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." );
138 return ( result != -1 ); 139 return ( result != -1 );
139} 140}
140 141
141/*====================================================================================== 142/*======================================================================================
142 * ONetworkInterface 143 * ONetworkInterface
143 *======================================================================================*/ 144 *======================================================================================*/
144 145
145ONetworkInterface::ONetworkInterface( const QString& name ) 146ONetworkInterface::ONetworkInterface( const QString& name )
146 :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 147 :_name( name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
147{ 148{
148 qDebug( "ONetworkInterface::ONetworkInterface()" ); 149 qDebug( "ONetworkInterface::ONetworkInterface()" );
149 init(); 150 init();
150} 151}
151 152
152 153
153ifreqstruct& ONetworkInterface::ifr() const 154ifreqstruct& ONetworkInterface::ifr() const
154{ 155{
155 return _ifr; 156 return _ifr;
156} 157}
157 158
158 159
159void ONetworkInterface::init() 160void ONetworkInterface::init()
160{ 161{
161 qDebug( "ONetworkInterface::init()" ); 162 qDebug( "ONetworkInterface::init()" );
162 163
163 memset( &_ifr, 0, sizeof( struct ifreq ) ); 164 memset( &_ifr, 0, sizeof( struct ifreq ) );
164 165
165 if ( _sfd == -1 ) 166 if ( _sfd == -1 )
166 { 167 {
167 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", (const char*) _name ); 168 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", (const char*) _name );
168 return; 169 return;
169 } 170 }
170} 171}
171 172
172 173
173bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const 174bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const
174{ 175{
175 int result = ::ioctl( _sfd, call, &ifreq ); 176 int result = ::ioctl( _sfd, call, &ifreq );
176 if ( result == -1 ) 177 if ( result == -1 )
177 qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); 178 qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) );
178 else 179 else
179 qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); 180 qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call );
180 return ( result != -1 ); 181 return ( result != -1 );
181} 182}
182 183
183 184
184bool ONetworkInterface::ioctl( int call ) const 185bool ONetworkInterface::ioctl( int call ) const
185{ 186{
186 strcpy( _ifr.ifr_name, (const char*) _name ); 187 strcpy( _ifr.ifr_name, (const char*) _name );
187 return ioctl( call, _ifr ); 188 return ioctl( call, _ifr );
188} 189}
189 190
190 191
191bool ONetworkInterface::isLoopback() const 192bool ONetworkInterface::isLoopback() const
192{ 193{
193 ioctl( SIOCGIFFLAGS ); 194 ioctl( SIOCGIFFLAGS );
194 return _ifr.ifr_flags & IFF_LOOPBACK; 195 return _ifr.ifr_flags & IFF_LOOPBACK;
195} 196}
196 197
197 198
198bool ONetworkInterface::setUp( bool b ) 199bool ONetworkInterface::setUp( bool b )
199{ 200{
200 ioctl( SIOCGIFFLAGS ); 201 ioctl( SIOCGIFFLAGS );
201 if ( b ) _ifr.ifr_flags |= IFF_UP; 202 if ( b ) _ifr.ifr_flags |= IFF_UP;
202 else _ifr.ifr_flags &= (~IFF_UP); 203 else _ifr.ifr_flags &= (~IFF_UP);
203 return ioctl( SIOCSIFFLAGS ); 204 return ioctl( SIOCSIFFLAGS );
204} 205}
205 206
206 207
207bool ONetworkInterface::isUp() const 208bool ONetworkInterface::isUp() const
208{ 209{
209 ioctl( SIOCGIFFLAGS ); 210 ioctl( SIOCGIFFLAGS );
210 return _ifr.ifr_flags & IFF_UP; 211 return _ifr.ifr_flags & IFF_UP;
211} 212}
212 213
213 214
214QString ONetworkInterface::ipV4Address() const 215QString ONetworkInterface::ipV4Address() const
215{ 216{
216 if ( ioctl( SIOCGIFADDR ) ) 217 if ( ioctl( SIOCGIFADDR ) )
217 { 218 {
218 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 219 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
219 //FIXME: Use QHostAddress here 220 //FIXME: Use QHostAddress here
220 return QString( inet_ntoa( sa->sin_addr ) ); 221 return QString( inet_ntoa( sa->sin_addr ) );
221 } 222 }
222 else 223 else
223 return "<unknown>"; 224 return "<unknown>";
224} 225}
225 226
226 227
227OMacAddress ONetworkInterface::macAddress() const 228OMacAddress ONetworkInterface::macAddress() const
228{ 229{
229 if ( ioctl( SIOCGIFHWADDR ) ) 230 if ( ioctl( SIOCGIFHWADDR ) )
230 { 231 {
231 return OMacAddress( _ifr ); 232 return OMacAddress( _ifr );
232 } 233 }
233 else 234 else
234 { 235 {
235 return OMacAddress::unknown; 236 return OMacAddress::unknown;
236 } 237 }
237} 238}
238 239
239 240
240void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 241void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
241{ 242{
242 _mon = m; 243 _mon = m;
243 qDebug( "ONetwork::setMonitoring(): Installed monitoring interface '%s'", (const char*) m->name() ); 244 qDebug( "ONetwork::setMonitoring(): Installed monitoring interface '%s'", (const char*) m->name() );
244} 245}
245 246
246 247
247OMonitoringInterface* ONetworkInterface::monitoring() const 248OMonitoringInterface* ONetworkInterface::monitoring() const
248{ 249{
249 return _mon; 250 return _mon;
250} 251}
251 252
252 253
253const QString& ONetworkInterface::name() const 254const QString& ONetworkInterface::name() const
254{ 255{
255 return _name; 256 return _name;
256} 257}
257 258
258 259
259ONetworkInterface::~ONetworkInterface() 260ONetworkInterface::~ONetworkInterface()
260{ 261{
261 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 262 qDebug( "ONetworkInterface::~ONetworkInterface()" );
262 if ( _sfd != -1 ) ::close( _sfd ); 263 if ( _sfd != -1 ) ::close( _sfd );
263} 264}
264 265
265 266
266bool ONetworkInterface::setPromiscuousMode( bool b ) 267bool ONetworkInterface::setPromiscuousMode( bool b )
267{ 268{
268 ioctl( SIOCGIFFLAGS ); 269 ioctl( SIOCGIFFLAGS );
269 if ( b ) _ifr.ifr_flags |= IFF_PROMISC; 270 if ( b ) _ifr.ifr_flags |= IFF_PROMISC;
270 else _ifr.ifr_flags &= (~IFF_PROMISC); 271 else _ifr.ifr_flags &= (~IFF_PROMISC);
271 return ioctl( SIOCSIFFLAGS ); 272 return ioctl( SIOCSIFFLAGS );
272} 273}
273 274
274 275
275bool ONetworkInterface::promiscuousMode() const 276bool ONetworkInterface::promiscuousMode() const
276{ 277{
277 ioctl( SIOCGIFFLAGS ); 278 ioctl( SIOCGIFFLAGS );
278 return _ifr.ifr_flags & IFF_PROMISC; 279 return _ifr.ifr_flags & IFF_PROMISC;
279} 280}
280 281
281 282
282bool ONetworkInterface::isWireless() const 283bool ONetworkInterface::isWireless() const
283{ 284{
284 return ioctl( SIOCGIWNAME ); 285 return ioctl( SIOCGIWNAME );
285} 286}
286 287
287 288
288/*====================================================================================== 289/*======================================================================================
289 * OChannelHopper 290 * OChannelHopper
290 *======================================================================================*/ 291 *======================================================================================*/
291 292
292OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) 293OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
293 :QObject( 0, "Mickey's funky hopper" ), 294 :QObject( 0, "Mickey's funky hopper" ),
294 _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ), 295 _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ),
295 _maxChannel( iface->channels()+1 ) 296 _maxChannel( iface->channels()+1 )
296{ 297{
297} 298}
298 299
299 300
300OChannelHopper::~OChannelHopper() 301OChannelHopper::~OChannelHopper()
301{ 302{
302} 303}
303 304
304 305
305bool OChannelHopper::isActive() const 306bool OChannelHopper::isActive() const
306{ 307{
307 return _tid; 308 return _tid;
308} 309}
309 310
310 311
311int OChannelHopper::channel() const 312int OChannelHopper::channel() const
312{ 313{
313 return _channel; 314 return _channel;
314} 315}
315 316
316 317
317void OChannelHopper::timerEvent( QTimerEvent* ) 318void OChannelHopper::timerEvent( QTimerEvent* )
318{ 319{
319 if ( !--_channel ) _channel = _maxChannel; 320 if ( !--_channel ) _channel = _maxChannel;
320 _iface->setChannel( _channel ); 321 _iface->setChannel( _channel );
321 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", 322 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'",
322 _channel, (const char*) _iface->name() ); 323 _channel, (const char*) _iface->name() );
323} 324}
324 325
325 326
326void OChannelHopper::setInterval( int interval ) 327void OChannelHopper::setInterval( int interval )
327{ 328{
328 if ( interval == _interval ) 329 if ( interval == _interval )
329 return; 330 return;
330 331
331 if ( _interval ) 332 if ( _interval )
332 killTimer( _tid ); 333 killTimer( _tid );
333 334
334 _tid = 0; 335 _tid = 0;
335 _interval = interval; 336 _interval = interval;
336 337
337 if ( _interval ) 338 if ( _interval )
338 { 339 {
339 _tid = startTimer( interval ); 340 _tid = startTimer( interval );
340 } 341 }
341} 342}
342 343
343 344
344int OChannelHopper::interval() const 345int OChannelHopper::interval() const
345{ 346{
346 return _interval; 347 return _interval;
347} 348}
348 349
349 350
350/*====================================================================================== 351/*======================================================================================
351 * OWirelessNetworkInterface 352 * OWirelessNetworkInterface
352 *======================================================================================*/ 353 *======================================================================================*/
353 354
354OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) 355OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name )
355 :ONetworkInterface( name ), _hopper( 0 ) 356 :ONetworkInterface( name ), _hopper( 0 )
356{ 357{
357 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 358 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
358 init(); 359 init();
359} 360}
360 361
361 362
362OWirelessNetworkInterface::~OWirelessNetworkInterface() 363OWirelessNetworkInterface::~OWirelessNetworkInterface()
363{ 364{
364} 365}
365 366
366 367
367iwreqstruct& OWirelessNetworkInterface::iwr() const 368iwreqstruct& OWirelessNetworkInterface::iwr() const
368{ 369{
369 return _iwr; 370 return _iwr;
370} 371}
371 372
372 373
373void OWirelessNetworkInterface::init() 374void OWirelessNetworkInterface::init()
374{ 375{
375 qDebug( "OWirelessNetworkInterface::init()" ); 376 qDebug( "OWirelessNetworkInterface::init()" );
376 377
377 memset( &_iwr, 0, sizeof( struct iwreq ) ); 378 memset( &_iwr, 0, sizeof( struct iwreq ) );
378 379
379 // IEEE802.11(b) radio frequency channels 380 // IEEE802.11(b) radio frequency channels
380 //FIXME: get these directly from the interface 381 //FIXME: get these directly from the interface
381 //FIXME: check if these channels are off-by-one 382 //FIXME: check if these channels are off-by-one
382 383
383 iwrangestruct range; 384 iwrangestruct range;
384 _iwr.u.data.pointer = (char*) &range; 385 _iwr.u.data.pointer = (char*) &range;
385 _iwr.u.data.length = sizeof( iwrangestruct ); 386 _iwr.u.data.length = sizeof( iwrangestruct );
386 if ( !wioctl( SIOCGIWRANGE ) ) 387 if ( !wioctl( SIOCGIWRANGE ) )
387 { 388 {
388 qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) ); 389 qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) );
389 return; 390 return;
390 } 391 }
391 392
392 for ( int i = 0; i < range.num_frequency; ++i ) 393 for ( int i = 0; i < range.num_frequency; ++i )
393 { 394 {
394 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); 395 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 );
395 _channels.insert( freq, i+1 ); 396 _channels.insert( freq, i+1 );
396 } 397 }
397} 398}
398 399
399 400
400QString OWirelessNetworkInterface::associatedAP() const 401QString OWirelessNetworkInterface::associatedAP() const
401{ 402{
402 //FIXME: use OMacAddress 403 //FIXME: use OMacAddress
403 QString mac; 404 QString mac;
404 405
405 if ( ioctl( SIOCGIWAP ) ) 406 if ( ioctl( SIOCGIWAP ) )
406 { 407 {
407 mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 408 mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
408 _ifr.ifr_hwaddr.sa_data[0]&0xff, 409 _ifr.ifr_hwaddr.sa_data[0]&0xff,
409 _ifr.ifr_hwaddr.sa_data[1]&0xff, 410 _ifr.ifr_hwaddr.sa_data[1]&0xff,
410 _ifr.ifr_hwaddr.sa_data[2]&0xff, 411 _ifr.ifr_hwaddr.sa_data[2]&0xff,
411 _ifr.ifr_hwaddr.sa_data[3]&0xff, 412 _ifr.ifr_hwaddr.sa_data[3]&0xff,
412 _ifr.ifr_hwaddr.sa_data[4]&0xff, 413 _ifr.ifr_hwaddr.sa_data[4]&0xff,
413 _ifr.ifr_hwaddr.sa_data[5]&0xff ); 414 _ifr.ifr_hwaddr.sa_data[5]&0xff );
414 } 415 }
415 else 416 else
416 { 417 {
417 mac = "<Unknown>"; 418 mac = "<Unknown>";
418 } 419 }
419 return mac; 420 return mac;
420} 421}
421 422
422 423
423int OWirelessNetworkInterface::channel() const 424int OWirelessNetworkInterface::channel() const
424{ 425{
425 //FIXME: When monitoring enabled, then use it 426 //FIXME: When monitoring enabled, then use it
426 //FIXME: to gather the current RF channel 427 //FIXME: to gather the current RF channel
427 //FIXME: Until then, get active channel from hopper. 428 //FIXME: Until then, get active channel from hopper.
428 if ( _hopper && _hopper->isActive() ) 429 if ( _hopper && _hopper->isActive() )
429 return _hopper->channel(); 430 return _hopper->channel();
430 431
431 if ( !wioctl( SIOCGIWFREQ ) ) 432 if ( !wioctl( SIOCGIWFREQ ) )
432 { 433 {
433 return -1; 434 return -1;
434 } 435 }
435 else 436 else
436 { 437 {
437 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; 438 return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ];
438 } 439 }
439} 440}
440 441
441 442
442void OWirelessNetworkInterface::setChannel( int c ) const 443void OWirelessNetworkInterface::setChannel( int c ) const
443{ 444{
444 if ( !_mon ) 445 if ( !_mon )
445 { 446 {
446 memset( &_iwr, 0, sizeof( iwreqstruct ) ); 447 memset( &_iwr, 0, sizeof( iwreqstruct ) );
447 _iwr.u.freq.m = c; 448 _iwr.u.freq.m = c;
448 _iwr.u.freq.e = 0; 449 _iwr.u.freq.e = 0;
449 wioctl( SIOCSIWFREQ ); 450 wioctl( SIOCSIWFREQ );
450 } 451 }
451 else 452 else
452 { 453 {
453 _mon->setChannel( c ); 454 _mon->setChannel( c );
454 } 455 }
455} 456}
456 457
457 458
458double OWirelessNetworkInterface::frequency() const 459double OWirelessNetworkInterface::frequency() const
459{ 460{
460 if ( !wioctl( SIOCGIWFREQ ) ) 461 if ( !wioctl( SIOCGIWFREQ ) )
461 { 462 {
462 return -1.0; 463 return -1.0;
463 } 464 }
464 else 465 else
465 { 466 {
466 return double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000000.0; 467 return double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000000.0;
467 } 468 }
468} 469}
469 470
470 471
471int OWirelessNetworkInterface::channels() const 472int OWirelessNetworkInterface::channels() const
472{ 473{
473 return _channels.count(); 474 return _channels.count();
474} 475}
475 476
476 477
477void OWirelessNetworkInterface::setChannelHopping( int interval ) 478void OWirelessNetworkInterface::setChannelHopping( int interval )
478{ 479{
479 if ( !_hopper ) _hopper = new OChannelHopper( this ); 480 if ( !_hopper ) _hopper = new OChannelHopper( this );
480 _hopper->setInterval( interval ); 481 _hopper->setInterval( interval );
481 //FIXME: When and by whom will the channel hopper be deleted? 482 //FIXME: When and by whom will the channel hopper be deleted?
482} 483}
483 484
484 485
485int OWirelessNetworkInterface::channelHopping() const 486int OWirelessNetworkInterface::channelHopping() const
486{ 487{
487 return _hopper->interval(); 488 return _hopper->interval();
488} 489}
489 490
490 491
491void OWirelessNetworkInterface::setMonitorMode( bool b ) 492void OWirelessNetworkInterface::setMonitorMode( bool b )
492{ 493{
493 if ( _mon ) 494 if ( _mon )
494 _mon->setEnabled( b ); 495 _mon->setEnabled( b );
495 else 496 else
496 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 497 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" );
497} 498}
498 499
499 500
500bool OWirelessNetworkInterface::monitorMode() const 501bool OWirelessNetworkInterface::monitorMode() const
501{ 502{
502 return _mon ? _mon->enabled() : false; 503 return _mon ? _mon->enabled() : false;
503} 504}
504 505
505 506
506QString OWirelessNetworkInterface::nickName() const 507QString OWirelessNetworkInterface::nickName() const
507{ 508{
508 char str[IW_ESSID_MAX_SIZE]; 509 char str[IW_ESSID_MAX_SIZE];
509 _iwr.u.data.pointer = &str[0]; 510 _iwr.u.data.pointer = &str[0];
510 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 511 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
511 if ( !wioctl( SIOCGIWNICKN ) ) 512 if ( !wioctl( SIOCGIWNICKN ) )
512 { 513 {
513 return "<unknown>"; 514 return "<unknown>";
514 } 515 }
515 else 516 else
516 { 517 {
517 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 518 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string
518 return str; 519 return str;
519 } 520 }
520} 521}
521 522
522 523
523QString OWirelessNetworkInterface::SSID() const 524QString OWirelessNetworkInterface::SSID() const
524{ 525{
525 char str[IW_ESSID_MAX_SIZE]; 526 char str[IW_ESSID_MAX_SIZE];
526 _iwr.u.essid.pointer = &str[0]; 527 _iwr.u.essid.pointer = &str[0];
527 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 528 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
528 if ( !wioctl( SIOCGIWESSID ) ) 529 if ( !wioctl( SIOCGIWESSID ) )
529 { 530 {
530 return "<unknown>"; 531 return "<unknown>";
531 } 532 }
532 else 533 else
533 { 534 {
534 return str; 535 return str;
535 } 536 }
536} 537}
537 538
538 539
539void OWirelessNetworkInterface::setSSID( const QString& ssid ) 540void OWirelessNetworkInterface::setSSID( const QString& ssid )
540{ 541{
541 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 542 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
542 _iwr.u.essid.length = ssid.length(); 543 _iwr.u.essid.length = ssid.length();
543 wioctl( SIOCSIWESSID ); 544 wioctl( SIOCSIWESSID );
544} 545}
545 546
546 547
547bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const 548bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const
548{ 549{
549 int result = ::ioctl( _sfd, call, &iwreq ); 550 int result = ::ioctl( _sfd, call, &iwreq );
550 if ( result == -1 ) 551 if ( result == -1 )
551 qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); 552 qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) );
552 else 553 else
553 qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); 554 qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call );
554 return ( result != -1 ); 555 return ( result != -1 );
555} 556}
556 557
557 558
558bool OWirelessNetworkInterface::wioctl( int call ) const 559bool OWirelessNetworkInterface::wioctl( int call ) const
559{ 560{
560 strcpy( _iwr.ifr_name, (const char*) _name ); 561 strcpy( _iwr.ifr_name, (const char*) _name );
561 return wioctl( call, _iwr ); 562 return wioctl( call, _iwr );
562} 563}
563 564
564 565
565/*====================================================================================== 566/*======================================================================================
566 * OMonitoringInterface 567 * OMonitoringInterface
567 *======================================================================================*/ 568 *======================================================================================*/
568 569
569OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) 570OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface )
570 :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) 571 :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) )
571{ 572{
572} 573}
573 574
574 575
575OMonitoringInterface::~OMonitoringInterface() 576OMonitoringInterface::~OMonitoringInterface()
576{ 577{
577} 578}
578 579
579 580
580void OMonitoringInterface::setChannel( int c ) 581void OMonitoringInterface::setChannel( int c )
581{ 582{
582 // use standard WE channel switching protocol 583 // use standard WE channel switching protocol
583 memset( &_if->_iwr, 0, sizeof( iwreqstruct ) ); 584 memset( &_if->_iwr, 0, sizeof( iwreqstruct ) );
584 _if->_iwr.u.freq.m = c; 585 _if->_iwr.u.freq.m = c;
585 _if->_iwr.u.freq.e = 0; 586 _if->_iwr.u.freq.e = 0;
586 _if->wioctl( SIOCSIWFREQ ); 587 _if->wioctl( SIOCSIWFREQ );
587} 588}
588 589
589 590
590bool OMonitoringInterface::enabled() const 591bool OMonitoringInterface::enabled() const
591{ 592{
592 return _enabled; 593 return _enabled;
593} 594}
594 595
595void OMonitoringInterface::setEnabled( bool b ) 596void OMonitoringInterface::setEnabled( bool b )
596{ 597{
597 // open a packet capturer here or leave this to 598 // open a packet capturer here or leave this to
598 // the client code? 599 // the client code?
599 600
600 /* 601 /*
601 602
602 if ( b ) 603 if ( b )
603 { 604 {
604 OPacketCapturer* opcap = new OPacketCapturer(); 605 OPacketCapturer* opcap = new OPacketCapturer();
605 opcap->open( _if->name() ); 606 opcap->open( _if->name() );
606 } 607 }
607 */ 608 */
608 609
609 _enabled = b; 610 _enabled = b;
610 611
611} 612}
612 613
613/*====================================================================================== 614/*======================================================================================
614 * OCiscoMonitoringInterface 615 * OCiscoMonitoringInterface
615 *======================================================================================*/ 616 *======================================================================================*/
616 617
617OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) 618OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface )
618 :OMonitoringInterface( iface ) 619 :OMonitoringInterface( iface )
619{ 620{
620 iface->setMonitoring( this ); 621 iface->setMonitoring( this );
621} 622}
622 623
623 624
624OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 625OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
625{ 626{
626} 627}
627 628
628 629
629void OCiscoMonitoringInterface::setEnabled( bool b ) 630void OCiscoMonitoringInterface::setEnabled( bool b )
630{ 631{
631 QString fname; 632 QString fname;
632 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 633 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
633 QFile f( fname ); 634 QFile f( fname );
634 if ( !f.exists() ) return; 635 if ( !f.exists() ) return;
635 636
636 if ( f.open( IO_WriteOnly ) ) 637 if ( f.open( IO_WriteOnly ) )
637 { 638 {
638 QTextStream s( &f ); 639 QTextStream s( &f );
639 s << "Mode: r"; 640 s << "Mode: r";
640 s << "Mode: y"; 641 s << "Mode: y";
641 s << "XmitPower: 1"; 642 s << "XmitPower: 1";
642 643
643 OMonitoringInterface::setEnabled( b ); 644 OMonitoringInterface::setEnabled( b );
644 645
645 } 646 }
646 647
647 // flushing and closing will be done automatically when f goes out of scope 648 // flushing and closing will be done automatically when f goes out of scope
648} 649}
649 650
650 651
651QString OCiscoMonitoringInterface::name() const 652QString OCiscoMonitoringInterface::name() const
652{ 653{
653 return "cisco"; 654 return "cisco";
654} 655}
655 656
656 657
657void OCiscoMonitoringInterface::setChannel( int ) 658void OCiscoMonitoringInterface::setChannel( int )
658{ 659{
659 // cisco devices automatically switch channels when in monitor mode 660 // cisco devices automatically switch channels when in monitor mode
660} 661}
661 662
662 663
663/*====================================================================================== 664/*======================================================================================
664 * OWlanNGMonitoringInterface 665 * OWlanNGMonitoringInterface
665 *======================================================================================*/ 666 *======================================================================================*/
666 667
667 668
668OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) 669OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface )
669 :OMonitoringInterface( iface ) 670 :OMonitoringInterface( iface )
670{ 671{
671 iface->setMonitoring( this ); 672 iface->setMonitoring( this );
672} 673}
673 674
674 675
675OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 676OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
676{ 677{
677} 678}
678 679
679 680
680void OWlanNGMonitoringInterface::setEnabled( bool b ) 681void OWlanNGMonitoringInterface::setEnabled( bool b )
681{ 682{
682 //FIXME: do nothing if its already in the same mode 683 //FIXME: do nothing if its already in the same mode
683 684
684 QString enable = b ? "true" : "false"; 685 QString enable = b ? "true" : "false";
685 QString cmd; 686 QString cmd;
686 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); 687 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable );
687 system( cmd ); 688 system( cmd );
688 689
689 OMonitoringInterface::setEnabled( b ); 690 OMonitoringInterface::setEnabled( b );
690} 691}
691 692
692 693
693QString OWlanNGMonitoringInterface::name() const 694QString OWlanNGMonitoringInterface::name() const
694{ 695{
695 return "wlan-ng"; 696 return "wlan-ng";
696} 697}
697 698
698 699
699void OWlanNGMonitoringInterface::setChannel( int ) 700void OWlanNGMonitoringInterface::setChannel( int )
700{ 701{
701 // wlan-ng devices automatically switch channels when in monitor mode 702 // wlan-ng devices automatically switch channels when in monitor mode
702} 703}
703 704
704 705
705/*====================================================================================== 706/*======================================================================================
706 * OHostAPMonitoringInterface 707 * OHostAPMonitoringInterface
707 *======================================================================================*/ 708 *======================================================================================*/
708 709
709OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) 710OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface )
710 :OMonitoringInterface( iface ) 711 :OMonitoringInterface( iface )
711{ 712{
712 iface->setMonitoring( this ); 713 iface->setMonitoring( this );
713} 714}
714 715
715OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 716OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
716{ 717{
717} 718}
718 719
719void OHostAPMonitoringInterface::setEnabled( bool b ) 720void OHostAPMonitoringInterface::setEnabled( bool b )
720{ 721{
721 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 722 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
722 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 723 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
723 724
724 #if WIRELESS_EXT > 14 725 #if WIRELESS_EXT > 14
725 _if->_iwr.u.mode = IW_MODE_MONITOR; 726 _if->_iwr.u.mode = IW_MODE_MONITOR;
726 _if->wioctl( SIOCSIWMODE ); 727 _if->wioctl( SIOCSIWMODE );
727 #else 728 #else
728 int* args = (int*) &_if._iwr.u.name; 729 int* args = (int*) &_if->_iwr.u.name;
729 args[0] = 2; 730 args[0] = 2;
730 args[1] = 0; 731 args[1] = 0;
731 _if->wioctl( SIOCDEVPRIVATE ); 732 _if->wioctl( SIOCDEVPRIVATE );
732 #endif 733 #endif
733 734
734 OMonitoringInterface::setEnabled( b ); 735 OMonitoringInterface::setEnabled( b );
735} 736}
736 737
737 738
738QString OHostAPMonitoringInterface::name() const 739QString OHostAPMonitoringInterface::name() const
739{ 740{
740 return "hostap"; 741 return "hostap";
741} 742}
742 743
743 744
744/*====================================================================================== 745/*======================================================================================
745 * OOrinocoNetworkInterface 746 * OOrinocoNetworkInterface
746 *======================================================================================*/ 747 *======================================================================================*/
747 748
748OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) 749OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface )
749 :OMonitoringInterface( iface ) 750 :OMonitoringInterface( iface )
750{ 751{
751 iface->setMonitoring( this ); 752 iface->setMonitoring( this );
752} 753}
753 754
754 755
755OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 756OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
756{ 757{
757} 758}
758 759
759 760
760void OOrinocoMonitoringInterface::setChannel( int c ) 761void OOrinocoMonitoringInterface::setChannel( int c )
761{ 762{
762 // call iwpriv <device> monitor 2 <channel> 763 // call iwpriv <device> monitor 2 <channel>
763 int* args = (int*) &_if->_iwr.u.name; 764 int* args = (int*) &_if->_iwr.u.name;
764 args[0] = 2; 765 args[0] = 2;
765 args[1] = c; 766 args[1] = c;
766 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); 767 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
767} 768}
768 769
769 770
770void OOrinocoMonitoringInterface::setEnabled( bool b ) 771void OOrinocoMonitoringInterface::setEnabled( bool b )
771{ 772{
772 if ( b ) 773 if ( b )
773 { 774 {
774 setChannel( 1 ); 775 setChannel( 1 );
775 } 776 }
776 else 777 else
777 { 778 {
778 // call iwpriv <device> monitor 0 0 779 // call iwpriv <device> monitor 0 0
779 int* args = (int*) &_if->_iwr.u.name; 780 int* args = (int*) &_if->_iwr.u.name;
780 args[0] = 0; 781 args[0] = 0;
781 args[1] = 0; 782 args[1] = 0;
782 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); 783 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
783 } 784 }
784 785
785 OMonitoringInterface::setEnabled( b ); 786 OMonitoringInterface::setEnabled( b );
786} 787}
787 788
788 789
789QString OOrinocoMonitoringInterface::name() const 790QString OOrinocoMonitoringInterface::name() const
790{ 791{
791 return "orinoco"; 792 return "orinoco";
792} 793}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 936ac85..56da5f4 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,310 +1,318 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* QT */ 37/* QT */
38 38
39#include <qdict.h> 39#include <qdict.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qhostaddress.h> 42#include <qhostaddress.h>
43 43
44/* OPIE */ 44/* OPIE */
45 45
46#include <opie2/onetutils.h> 46#include <opie2/onetutils.h>
47 47
48// ML: Yeah, I hate to include kernel headers, but it's necessary here 48// ML: Yeah, I hate to include kernel headers, but it's necessary here
49// ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something 49// ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something
50// ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h> 50// ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h>
51
52#ifndef IFNAMSIZ
51#define IFNAMSIZ 16 53#define IFNAMSIZ 16
54#endif
55
52#include <linux/wireless.h> 56#include <linux/wireless.h>
53#include <net/if.h> 57#include <net/if.h>
54 58
59#ifndef SIOCIWFIRSTPRIV
60#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
61#endif
62
55class ONetworkInterface; 63class ONetworkInterface;
56class OWirelessNetworkInterface; 64class OWirelessNetworkInterface;
57class OChannelHopper; 65class OChannelHopper;
58class OMonitoringInterface; 66class OMonitoringInterface;
59 67
60typedef struct ifreq ifreqstruct; 68typedef struct ifreq ifreqstruct;
61typedef struct iwreq iwreqstruct; 69typedef struct iwreq iwreqstruct;
62typedef struct iw_event iweventstruct; 70typedef struct iw_event iweventstruct;
63typedef struct iw_freq iwfreqstruct; 71typedef struct iw_freq iwfreqstruct;
64typedef struct iw_priv_args iwprivargsstruct; 72typedef struct iw_priv_args iwprivargsstruct;
65typedef struct iw_range iwrangestruct; 73typedef struct iw_range iwrangestruct;
66 74
67/*====================================================================================== 75/*======================================================================================
68 * ONetwork 76 * ONetwork
69 *======================================================================================*/ 77 *======================================================================================*/
70 78
71class ONetwork : public QObject 79class ONetwork : public QObject
72{ 80{
73 Q_OBJECT 81 Q_OBJECT
74 82
75 public: 83 public:
76 typedef QDict<ONetworkInterface> InterfaceMap; 84 typedef QDict<ONetworkInterface> InterfaceMap;
77 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 85 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
78 86
79 public: 87 public:
80 static ONetwork* instance(); 88 static ONetwork* instance();
81 InterfaceIterator iterator() const; 89 InterfaceIterator iterator() const;
82 bool isWirelessInterface( const char* ) const; 90 bool isWirelessInterface( const char* ) const;
83 ONetworkInterface* interface( QString ) const; 91 ONetworkInterface* interface( QString ) const;
84 92
85 protected: 93 protected:
86 ONetwork(); 94 ONetwork();
87 void synchronize(); 95 void synchronize();
88 96
89 private: 97 private:
90 static ONetwork* _instance; 98 static ONetwork* _instance;
91 InterfaceMap _interfaces; 99 InterfaceMap _interfaces;
92}; 100};
93 101
94 102
95/*====================================================================================== 103/*======================================================================================
96 * ONetworkInterface 104 * ONetworkInterface
97 *======================================================================================*/ 105 *======================================================================================*/
98 106
99class ONetworkInterface 107class ONetworkInterface
100{ 108{
101 friend class OMonitoringInterface; 109 friend class OMonitoringInterface;
102 friend class OCiscoMonitoringInterface; 110 friend class OCiscoMonitoringInterface;
103 friend class OWlanNGMonitoringInterface; 111 friend class OWlanNGMonitoringInterface;
104 friend class OHostAPMonitoringInterface; 112 friend class OHostAPMonitoringInterface;
105 friend class OOrinocoMonitoringInterface; 113 friend class OOrinocoMonitoringInterface;
106 114
107 public: 115 public:
108 ONetworkInterface( const QString& name ); 116 ONetworkInterface( const QString& name );
109 virtual ~ONetworkInterface(); 117 virtual ~ONetworkInterface();
110 118
111 const QString& name() const; 119 const QString& name() const;
112 void setMonitoring( OMonitoringInterface* ); 120 void setMonitoring( OMonitoringInterface* );
113 OMonitoringInterface* monitoring() const; 121 OMonitoringInterface* monitoring() const;
114 bool setPromiscuousMode( bool ); 122 bool setPromiscuousMode( bool );
115 bool promiscuousMode() const; 123 bool promiscuousMode() const;
116 bool setUp( bool ); 124 bool setUp( bool );
117 bool isUp() const; 125 bool isUp() const;
118 bool isLoopback() const; 126 bool isLoopback() const;
119 bool isWireless() const; 127 bool isWireless() const;
120 QString ipV4Address() const; 128 QString ipV4Address() const;
121 OMacAddress macAddress() const; 129 OMacAddress macAddress() const;
122 130
123 protected: 131 protected:
124 const QString _name; 132 const QString _name;
125 const int _sfd; 133 const int _sfd;
126 mutable ifreqstruct _ifr; 134 mutable ifreqstruct _ifr;
127 OMonitoringInterface* _mon; 135 OMonitoringInterface* _mon;
128 136
129 protected: 137 protected:
130 ifreqstruct& ifr() const; 138 ifreqstruct& ifr() const;
131 virtual void init(); 139 virtual void init();
132 bool ioctl( int call ) const; 140 bool ioctl( int call ) const;
133 bool ioctl( int call, ifreqstruct& ) const; 141 bool ioctl( int call, ifreqstruct& ) const;
134}; 142};
135 143
136/*====================================================================================== 144/*======================================================================================
137 * OChannelHopper 145 * OChannelHopper
138 *======================================================================================*/ 146 *======================================================================================*/
139 147
140class OChannelHopper : public QObject 148class OChannelHopper : public QObject
141{ 149{
142 public: 150 public:
143 OChannelHopper( OWirelessNetworkInterface* ); 151 OChannelHopper( OWirelessNetworkInterface* );
144 virtual ~OChannelHopper(); 152 virtual ~OChannelHopper();
145 bool isActive() const; 153 bool isActive() const;
146 int channel() const; 154 int channel() const;
147 virtual void timerEvent( QTimerEvent* ); 155 virtual void timerEvent( QTimerEvent* );
148 void setInterval( int ); 156 void setInterval( int );
149 int interval() const; 157 int interval() const;
150 158
151 private: 159 private:
152 OWirelessNetworkInterface* _iface; 160 OWirelessNetworkInterface* _iface;
153 int _interval; 161 int _interval;
154 int _channel; 162 int _channel;
155 int _tid; 163 int _tid;
156 int _maxChannel; 164 int _maxChannel;
157}; 165};
158 166
159 167
160/*====================================================================================== 168/*======================================================================================
161 * OWirelessNetworkInterface 169 * OWirelessNetworkInterface
162 *======================================================================================*/ 170 *======================================================================================*/
163 171
164class OWirelessNetworkInterface : public ONetworkInterface 172class OWirelessNetworkInterface : public ONetworkInterface
165{ 173{
166 friend class OMonitoringInterface; 174 friend class OMonitoringInterface;
167 friend class OCiscoMonitoringInterface; 175 friend class OCiscoMonitoringInterface;
168 friend class OWlanNGMonitoringInterface; 176 friend class OWlanNGMonitoringInterface;
169 friend class OHostAPMonitoringInterface; 177 friend class OHostAPMonitoringInterface;
170 friend class OOrinocoMonitoringInterface; 178 friend class OOrinocoMonitoringInterface;
171 179
172 public: 180 public:
173 enum Mode { AdHoc, Managed, Monitor }; 181 enum Mode { AdHoc, Managed, Monitor };
174 182
175 OWirelessNetworkInterface( const QString& name ); 183 OWirelessNetworkInterface( const QString& name );
176 virtual ~OWirelessNetworkInterface(); 184 virtual ~OWirelessNetworkInterface();
177 185
178 virtual void setChannel( int ) const; 186 virtual void setChannel( int ) const;
179 virtual int channel() const; 187 virtual int channel() const;
180 virtual double frequency() const; 188 virtual double frequency() const;
181 virtual int channels() const; 189 virtual int channels() const;
182 //virtual double frequency(int) const; 190 //virtual double frequency(int) const;
183 191
184 virtual void setMode( Mode ) {}; 192 virtual void setMode( Mode ) {};
185 virtual bool mode() const {}; 193 virtual bool mode() const {};
186 194
187 virtual void setMonitorMode( bool ); 195 virtual void setMonitorMode( bool );
188 virtual bool monitorMode() const; 196 virtual bool monitorMode() const;
189 197
190 virtual void setChannelHopping( int interval = 0 ); 198 virtual void setChannelHopping( int interval = 0 );
191 virtual int channelHopping() const; 199 virtual int channelHopping() const;
192 200
193 virtual void setNickName( const QString& ) {}; 201 virtual void setNickName( const QString& ) {};
194 virtual QString nickName() const; 202 virtual QString nickName() const;
195 203
196 virtual bool isAssociated() const {}; 204 virtual bool isAssociated() const {};
197 virtual QString associatedAP() const; 205 virtual QString associatedAP() const;
198 206
199 virtual void setSSID( const QString& ); 207 virtual void setSSID( const QString& );
200 virtual QString SSID() const; 208 virtual QString SSID() const;
201 209
202 protected: 210 protected:
203 mutable iwreqstruct _iwr; 211 mutable iwreqstruct _iwr;
204 QMap<int,int> _channels; 212 QMap<int,int> _channels;
205 213
206 protected: 214 protected:
207 virtual void init(); 215 virtual void init();
208 iwreqstruct& iwr() const; 216 iwreqstruct& iwr() const;
209 bool wioctl( int call ) const; 217 bool wioctl( int call ) const;
210 bool wioctl( int call, iwreqstruct& ) const; 218 bool wioctl( int call, iwreqstruct& ) const;
211 219
212 private: 220 private:
213 OChannelHopper* _hopper; 221 OChannelHopper* _hopper;
214}; 222};
215 223
216 224
217/*====================================================================================== 225/*======================================================================================
218 * OMonitoringInterface 226 * OMonitoringInterface
219 *======================================================================================*/ 227 *======================================================================================*/
220 228
221 229
222class OMonitoringInterface 230class OMonitoringInterface
223{ 231{
224 public: 232 public:
225 OMonitoringInterface(); 233 OMonitoringInterface();
226 OMonitoringInterface( ONetworkInterface* ); 234 OMonitoringInterface( ONetworkInterface* );
227 virtual ~OMonitoringInterface(); 235 virtual ~OMonitoringInterface();
228 236
229 public: 237 public:
230 virtual void setEnabled( bool ); 238 virtual void setEnabled( bool );
231 virtual bool enabled() const; 239 virtual bool enabled() const;
232 virtual void setChannel( int ); 240 virtual void setChannel( int );
233 241
234 virtual QString name() const = 0; 242 virtual QString name() const = 0;
235 243
236 protected: 244 protected:
237 bool _enabled; 245 bool _enabled;
238 const OWirelessNetworkInterface* _if; 246 const OWirelessNetworkInterface* _if;
239 247
240}; 248};
241 249
242 250
243/*====================================================================================== 251/*======================================================================================
244 * OCiscoMonitoring 252 * OCiscoMonitoring
245 *======================================================================================*/ 253 *======================================================================================*/
246 254
247 255
248class OCiscoMonitoringInterface : public OMonitoringInterface 256class OCiscoMonitoringInterface : public OMonitoringInterface
249{ 257{
250 public: 258 public:
251 OCiscoMonitoringInterface( ONetworkInterface* ); 259 OCiscoMonitoringInterface( ONetworkInterface* );
252 virtual ~OCiscoMonitoringInterface(); 260 virtual ~OCiscoMonitoringInterface();
253 261
254 virtual void setEnabled( bool ); 262 virtual void setEnabled( bool );
255 virtual QString name() const; 263 virtual QString name() const;
256 virtual void setChannel( int ); 264 virtual void setChannel( int );
257 265
258}; 266};
259 267
260/*====================================================================================== 268/*======================================================================================
261 * OWlanNGMonitoringInterface 269 * OWlanNGMonitoringInterface
262 *======================================================================================*/ 270 *======================================================================================*/
263 271
264class OWlanNGMonitoringInterface : public OMonitoringInterface 272class OWlanNGMonitoringInterface : public OMonitoringInterface
265{ 273{
266 public: 274 public:
267 OWlanNGMonitoringInterface( ONetworkInterface* ); 275 OWlanNGMonitoringInterface( ONetworkInterface* );
268 virtual ~OWlanNGMonitoringInterface(); 276 virtual ~OWlanNGMonitoringInterface();
269 277
270 public: 278 public:
271 virtual void setEnabled( bool ); 279 virtual void setEnabled( bool );
272 virtual QString name() const; 280 virtual QString name() const;
273 virtual void setChannel( int ); 281 virtual void setChannel( int );
274 282
275}; 283};
276 284
277/*====================================================================================== 285/*======================================================================================
278 * OHostAPMonitoringInterface 286 * OHostAPMonitoringInterface
279 *======================================================================================*/ 287 *======================================================================================*/
280 288
281class OHostAPMonitoringInterface : public OMonitoringInterface 289class OHostAPMonitoringInterface : public OMonitoringInterface
282{ 290{
283 public: 291 public:
284 OHostAPMonitoringInterface( ONetworkInterface* ); 292 OHostAPMonitoringInterface( ONetworkInterface* );
285 virtual ~OHostAPMonitoringInterface(); 293 virtual ~OHostAPMonitoringInterface();
286 294
287 public: 295 public:
288 virtual void setEnabled( bool ); 296 virtual void setEnabled( bool );
289 virtual QString name() const; 297 virtual QString name() const;
290 }; 298 };
291 299
292/*====================================================================================== 300/*======================================================================================
293 * OOrinocoMonitoringInterface 301 * OOrinocoMonitoringInterface
294 *======================================================================================*/ 302 *======================================================================================*/
295 303
296class OOrinocoMonitoringInterface : public OMonitoringInterface 304class OOrinocoMonitoringInterface : public OMonitoringInterface
297{ 305{
298 public: 306 public:
299 OOrinocoMonitoringInterface( ONetworkInterface* ); 307 OOrinocoMonitoringInterface( ONetworkInterface* );
300 virtual ~OOrinocoMonitoringInterface(); 308 virtual ~OOrinocoMonitoringInterface();
301 309
302 public: 310 public:
303 virtual void setChannel( int ); 311 virtual void setChannel( int );
304 virtual void setEnabled( bool ); 312 virtual void setEnabled( bool );
305 virtual QString name() const; 313 virtual QString name() const;
306 314
307}; 315};
308 316
309#endif // ONETWORK_H 317#endif // ONETWORK_H
310 318