author | mickeyl <mickeyl> | 2003-05-05 22:27:58 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-05 22:27:58 (UTC) |
commit | 1a194aafffe37127758036e80ff55ead0c0e118d (patch) (unidiff) | |
tree | 9880a12153767027386c05a808dbeea64bf33ae4 /noncore/net/wellenreiter/gui | |
parent | 58a78cbe1bc5ded219ba23432041f20e03404403 (diff) | |
download | opie-1a194aafffe37127758036e80ff55ead0c0e118d.zip opie-1a194aafffe37127758036e80ff55ead0c0e118d.tar.gz opie-1a194aafffe37127758036e80ff55ead0c0e118d.tar.bz2 |
re-add
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 170 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 61 |
2 files changed, 231 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp new file mode 100644 index 0000000..2305403 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -0,0 +1,170 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | /* LOCAL */ | ||
17 | #include "configwindow.h" | ||
18 | #include "mainwindow.h" | ||
19 | |||
20 | /* QT */ | ||
21 | #include <qapplication.h> | ||
22 | #include <qcheckbox.h> | ||
23 | #include <qcombobox.h> | ||
24 | #include <qfile.h> | ||
25 | #include <qlineedit.h> | ||
26 | #include <qlayout.h> | ||
27 | #include <qmap.h> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qtoolbutton.h> | ||
30 | #include <qspinbox.h> | ||
31 | #include <qtextstream.h> | ||
32 | |||
33 | /* OPIE */ | ||
34 | #include <opie2/onetwork.h> | ||
35 | |||
36 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | ||
37 | |||
38 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | ||
39 | :WellenreiterConfigBase( parent, name, true, f ) | ||
40 | { | ||
41 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | ||
42 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | ||
43 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | ||
44 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | ||
45 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | ||
46 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | ||
47 | |||
48 | // gather possible interface names from ONetwork | ||
49 | ONetwork* net = ONetwork::instance(); | ||
50 | ONetwork::InterfaceIterator it = net->iterator(); | ||
51 | while ( it.current() ) | ||
52 | { | ||
53 | if ( it.current()->isWireless() ) | ||
54 | interfaceName->insertItem( it.current()->name() ); | ||
55 | ++it; | ||
56 | } | ||
57 | |||
58 | // try to guess device type | ||
59 | QFile m( "/proc/modules" ); | ||
60 | if ( m.open( IO_ReadOnly ) ) | ||
61 | { | ||
62 | int devicetype(0); | ||
63 | QString line; | ||
64 | QTextStream modules( &m ); | ||
65 | while( !modules.atEnd() && !devicetype ) | ||
66 | { | ||
67 | modules >> line; | ||
68 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | ||
69 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | ||
70 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | ||
71 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | ||
72 | } | ||
73 | if ( devicetype ) | ||
74 | { | ||
75 | deviceType->setCurrentItem( devicetype ); | ||
76 | _guess = devicetype; | ||
77 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | ||
82 | QPushButton* okButton = new QPushButton( "ok", this ); | ||
83 | okButton->show(); | ||
84 | Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | ||
85 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | ||
86 | #endif | ||
87 | |||
88 | WellenreiterConfigWindow::_instance = this; | ||
89 | |||
90 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | ||
91 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | ||
92 | |||
93 | // make the checkbox 'channelAll' control all other channels | ||
94 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | ||
95 | }; | ||
96 | |||
97 | |||
98 | int WellenreiterConfigWindow::driverType() const | ||
99 | { | ||
100 | QString name = deviceType->currentText(); | ||
101 | if ( _devicetype.contains( name ) ) | ||
102 | { | ||
103 | return _devicetype[name]; | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | return 0; | ||
108 | } | ||
109 | }; | ||
110 | |||
111 | |||
112 | int WellenreiterConfigWindow::hoppingInterval() const | ||
113 | { | ||
114 | return hopInterval->cleanText().toInt(); | ||
115 | } | ||
116 | |||
117 | |||
118 | bool WellenreiterConfigWindow::usePrismHeader() | ||
119 | { | ||
120 | return prismHeader->isOn(); | ||
121 | } | ||
122 | |||
123 | |||
124 | void WellenreiterConfigWindow::changedDeviceType(int t) | ||
125 | { | ||
126 | if ( t != DEVTYPE_FILE ) return; | ||
127 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); | ||
128 | if ( !name.isEmpty() && QFile::exists( name ) ) | ||
129 | { | ||
130 | interfaceName->insertItem( name ); | ||
131 | interfaceName->setCurrentItem( interfaceName->count()-1 ); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | deviceType->setCurrentItem( _guess ); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | |||
141 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | ||
142 | { | ||
143 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | ||
144 | qDebug( "name = %s", (const char*) name ); | ||
145 | if ( !name.isEmpty() ) | ||
146 | { | ||
147 | captureFileName->setText( name ); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | |||
152 | void WellenreiterConfigWindow::channelAllClicked(int state) | ||
153 | { | ||
154 | bool b = state; | ||
155 | channel1->setChecked( b ); | ||
156 | channel2->setChecked( b ); | ||
157 | channel3->setChecked( b ); | ||
158 | channel4->setChecked( b ); | ||
159 | channel5->setChecked( b ); | ||
160 | channel6->setChecked( b ); | ||
161 | channel7->setChecked( b ); | ||
162 | channel8->setChecked( b ); | ||
163 | channel9->setChecked( b ); | ||
164 | channel10->setChecked( b ); | ||
165 | channel11->setChecked( b ); | ||
166 | channel12->setChecked( b ); | ||
167 | channel13->setChecked( b ); | ||
168 | channel14->setChecked( b ); | ||
169 | } | ||
170 | |||
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h new file mode 100644 index 0000000..057bed6 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/configwindow.h | |||
@@ -0,0 +1,61 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef WELLENREITERCONFIGWINDOW_H | ||
17 | #define WELLENREITERCONFIGWINDOW_H | ||
18 | |||
19 | #include "configbase.h" | ||
20 | #include <qmap.h> | ||
21 | #include <qcombobox.h> | ||
22 | #include <qstring.h> | ||
23 | |||
24 | const int DEVTYPE_SELECT = 0; | ||
25 | const int DEVTYPE_CISCO = 1; | ||
26 | const int DEVTYPE_WLAN_NG = 2; | ||
27 | const int DEVTYPE_HOSTAP = 3; | ||
28 | const int DEVTYPE_ORINOCO = 4; | ||
29 | const int DEVTYPE_MANUAL = 5; | ||
30 | const int DEVTYPE_FILE = 6; | ||
31 | |||
32 | class WellenreiterConfigWindow; | ||
33 | |||
34 | class WellenreiterConfigWindow : public WellenreiterConfigBase | ||
35 | { | ||
36 | Q_OBJECT | ||
37 | |||
38 | public: | ||
39 | WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); | ||
40 | int driverType() const; | ||
41 | int hoppingInterval() const; | ||
42 | const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; | ||
43 | const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; | ||
44 | static WellenreiterConfigWindow* instance() { return _instance; }; | ||
45 | |||
46 | bool usePrismHeader(); | ||
47 | |||
48 | public slots: | ||
49 | void changedDeviceType(int); | ||
50 | void getCaptureFileNameClicked(); | ||
51 | |||
52 | void channelAllClicked(int); | ||
53 | |||
54 | protected: | ||
55 | QMap<QString, int> _devicetype; | ||
56 | static WellenreiterConfigWindow* _instance; | ||
57 | int _guess; | ||
58 | |||
59 | }; | ||
60 | |||
61 | #endif | ||