author | mickeyl <mickeyl> | 2003-10-04 00:30:57 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-04 00:30:57 (UTC) |
commit | e2716e3862915582d0ce48aaacc967f5b0cf6550 (patch) (unidiff) | |
tree | a27e94a9d813f843dcb26c22ee31f7ce21142109 /noncore/net/wellenreiter/gui/configwindow.cpp | |
parent | 120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed (diff) | |
download | opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.zip opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.gz opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.bz2 |
perform autodetection only if no configuration exists or on demand
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 98 |
1 files changed, 68 insertions, 30 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 84d4c63..3ec190b 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -59,27 +59,3 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char | |||
59 | 59 | ||
60 | if ( !load() ) // no configuration present | 60 | load(); |
61 | { | ||
62 | // try to guess device type | ||
63 | QFile m( "/proc/modules" ); | ||
64 | if ( m.open( IO_ReadOnly ) ) | ||
65 | { | ||
66 | int devicetype(0); | ||
67 | QString line; | ||
68 | QTextStream modules( &m ); | ||
69 | while( !modules.atEnd() && !devicetype ) | ||
70 | { | ||
71 | modules >> line; | ||
72 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | ||
73 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | ||
74 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | ||
75 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | ||
76 | } | ||
77 | if ( devicetype ) | ||
78 | { | ||
79 | deviceType->setCurrentItem( devicetype ); | ||
80 | _guess = devicetype; | ||
81 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | 61 | ||
@@ -99,2 +75,4 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char | |||
99 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 75 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
76 | |||
77 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | ||
100 | }; | 78 | }; |
@@ -108,2 +86,35 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow() | |||
108 | 86 | ||
87 | void WellenreiterConfigWindow::performAutodetection() | ||
88 | { | ||
89 | //TODO: insert modal splash screen here | ||
90 | // and sleep a second, so that it looks | ||
91 | // like we're actually doing something fancy... ;-) | ||
92 | |||
93 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | ||
94 | |||
95 | // try to guess device type | ||
96 | QFile m( "/proc/modules" ); | ||
97 | if ( m.open( IO_ReadOnly ) ) | ||
98 | { | ||
99 | int devicetype(0); | ||
100 | QString line; | ||
101 | QTextStream modules( &m ); | ||
102 | while( !modules.atEnd() && !devicetype ) | ||
103 | { | ||
104 | modules >> line; | ||
105 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | ||
106 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | ||
107 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | ||
108 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | ||
109 | } | ||
110 | if ( devicetype ) | ||
111 | { | ||
112 | deviceType->setCurrentItem( devicetype ); | ||
113 | _guess = devicetype; | ||
114 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | |||
109 | int WellenreiterConfigWindow::driverType() const | 120 | int WellenreiterConfigWindow::driverType() const |
@@ -223,3 +234,3 @@ int WellenreiterConfigWindow::gpsPort() const | |||
223 | 234 | ||
224 | bool WellenreiterConfigWindow::load() | 235 | void WellenreiterConfigWindow::load() |
225 | { | 236 | { |
@@ -227,3 +238,3 @@ bool WellenreiterConfigWindow::load() | |||
227 | #warning Persistent Configuration not yet implemented for standalone X11 build | 238 | #warning Persistent Configuration not yet implemented for standalone X11 build |
228 | return false; | 239 | performAutodetection(); |
229 | #else | 240 | #else |
@@ -236,4 +247,32 @@ bool WellenreiterConfigWindow::load() | |||
236 | c->setGroup( "Interface" ); | 247 | c->setGroup( "Interface" ); |
237 | //interfaceName->setCurrentText( c->readEntry( "name" ) ); | 248 | |
238 | //deviceType->setCurrentText( c->readEntry( "type", "<select>" ) ); | 249 | QString interface = c->readEntry( "name", "<none>" ); |
250 | if ( interface != "<none>" ) | ||
251 | { | ||
252 | #if QT_VERSION < 300 | ||
253 | interfaceName->insertItem( interface, 0 ); | ||
254 | interfaceName->setCurrentItem( 0 ); | ||
255 | #else | ||
256 | interfaceName->setCurrentText( interface ); | ||
257 | #endif | ||
258 | |||
259 | QString device = c->readEntry( "type", "<select>" ); | ||
260 | #if QT_VERSION < 300 | ||
261 | for ( int i = 0; i < deviceType->count(); ++i ) | ||
262 | { | ||
263 | if ( deviceType->text( i ) == device ) | ||
264 | { | ||
265 | deviceType->setCurrentItem( i ); | ||
266 | break; | ||
267 | } | ||
268 | } | ||
269 | #else | ||
270 | deviceType->setCurrentText( device ); | ||
271 | #endif | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | performAutodetection(); | ||
276 | } | ||
277 | |||
239 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 278 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
@@ -263,3 +302,2 @@ bool WellenreiterConfigWindow::load() | |||
263 | 302 | ||
264 | return false; // false = perform autodetection; true = use config settings | ||
265 | #endif | 303 | #endif |