Diffstat (limited to 'noncore/settings/networksettings/wlan/wlanimp2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp2.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index e7d6ff5..92339d6 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,79 +1,79 @@ | |||
1 | #include "wlanimp2.h" | 1 | #include "wlanimp2.h" |
2 | #include "keyedit.h" | 2 | #include "keyedit.h" |
3 | #include "interfacesetupimp.h" | 3 | #include "interfacesetupimp.h" |
4 | 4 | ||
5 | #include "../interfaces/interface.h" | 5 | #include "../interfaces/interface.h" |
6 | 6 | ||
7 | #include <assert.h> | 7 | #include <assert.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include <qfile.h> | 12 | #include <qfile.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | #include <qdialog.h> | 14 | #include <qdialog.h> |
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qlineedit.h> | 17 | #include <qlineedit.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <qradiobutton.h> | 20 | #include <qradiobutton.h> |
21 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qprogressbar.h> | 27 | #include <qprogressbar.h> |
28 | 28 | ||
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <opie/oprocess.h> | 31 | #include <opie2/oprocess.h> |
32 | #include <opie2/onetwork.h> | 32 | #include <opie2/onetwork.h> |
33 | #include <opie2/opcap.h> | 33 | #include <opie2/opcap.h> |
34 | #else | 34 | #else |
35 | #define OProcess KProcess | 35 | #define OProcess KProcess |
36 | #include <kprocess.h> | 36 | #include <kprocess.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" | 40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Constructor, read in the wireless.opts file for parsing later. | 43 | * Constructor, read in the wireless.opts file for parsing later. |
44 | */ | 44 | */ |
45 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 45 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
46 | interfaces = new Interfaces(); | 46 | interfaces = new Interfaces(); |
47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
49 | 49 | ||
50 | // Check sanity - the existance of the wireless-tools if-pre-up script | 50 | // Check sanity - the existance of the wireless-tools if-pre-up script |
51 | QFile file(QString(PREUP)); | 51 | QFile file(QString(PREUP)); |
52 | if (file.exists()) { | 52 | if (file.exists()) { |
53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
54 | } | 54 | } |
55 | 55 | ||
56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
57 | connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) ); | 57 | connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) ); |
58 | netView->setColumnAlignment( col_chn, AlignCenter ); | 58 | netView->setColumnAlignment( col_chn, AlignCenter ); |
59 | netView->setItemMargin( 3 ); | 59 | netView->setItemMargin( 3 ); |
60 | netView->setAllColumnsShowFocus( true ); | 60 | netView->setAllColumnsShowFocus( true ); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | WLANImp::~WLANImp() { | 64 | WLANImp::~WLANImp() { |
65 | //FIXME: delete interfaces; | 65 | //FIXME: delete interfaces; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Change the profile for both wireless settings and network settings. | 69 | * Change the profile for both wireless settings and network settings. |
70 | */ | 70 | */ |
71 | void WLANImp::setProfile(const QString &profile){ | 71 | void WLANImp::setProfile(const QString &profile){ |
72 | interfaceSetup->setProfile(profile); | 72 | interfaceSetup->setProfile(profile); |
73 | parseOpts(); | 73 | parseOpts(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void WLANImp::parseOpts() { | 76 | void WLANImp::parseOpts() { |
77 | bool error; | 77 | bool error; |
78 | QString opt; | 78 | QString opt; |
79 | 79 | ||
@@ -94,137 +94,137 @@ void WLANImp::parseOpts() { | |||
94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); | 94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
95 | 95 | ||
96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
97 | if (! opt.isNull()) { | 97 | if (! opt.isNull()) { |
98 | specifyAp->setChecked(true); | 98 | specifyAp->setChecked(true); |
99 | macEdit->setText(opt); | 99 | macEdit->setText(opt); |
100 | } | 100 | } |
101 | 101 | ||
102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
103 | if (! opt.isNull()) { | 103 | if (! opt.isNull()) { |
104 | specifyChan->setChecked(true); | 104 | specifyChan->setChecked(true); |
105 | networkChannel->setValue(opt.toInt()); | 105 | networkChannel->setValue(opt.toInt()); |
106 | } | 106 | } |
107 | 107 | ||
108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
109 | if (opt.isNull()) | 109 | if (opt.isNull()) |
110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
111 | parseKeyStr(opt); | 111 | parseKeyStr(opt); |
112 | } | 112 | } |
113 | 113 | ||
114 | void WLANImp::parseKeyStr(QString keystr) { | 114 | void WLANImp::parseKeyStr(QString keystr) { |
115 | int loc = 0; | 115 | int loc = 0; |
116 | int index = 1; | 116 | int index = 1; |
117 | QString key; | 117 | QString key; |
118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
119 | int enc = -1; // encryption state | 119 | int enc = -1; // encryption state |
120 | 120 | ||
121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
122 | if ((*it).left(3) == "off") { | 122 | if ((*it).left(3) == "off") { |
123 | // encryption disabled | 123 | // encryption disabled |
124 | enc = 0; | 124 | enc = 0; |
125 | } else if ((*it).left(2) == "on") { | 125 | } else if ((*it).left(2) == "on") { |
126 | // encryption enabled | 126 | // encryption enabled |
127 | enc = 1; | 127 | enc = 1; |
128 | } else if ((*it).left(4) == "open") { | 128 | } else if ((*it).left(4) == "open") { |
129 | // open mode, accept non encrypted packets | 129 | // open mode, accept non encrypted packets |
130 | acceptNonEnc->setChecked(true); | 130 | acceptNonEnc->setChecked(true); |
131 | } else if ((*it).left(10) == "restricted") { | 131 | } else if ((*it).left(10) == "restricted") { |
132 | // restricted mode, only accept encrypted packets | 132 | // restricted mode, only accept encrypted packets |
133 | rejectNonEnc->setChecked(true); | 133 | rejectNonEnc->setChecked(true); |
134 | } else if ((*it).left(3) == "key") { | 134 | } else if ((*it).left(3) == "key") { |
135 | // new set of options | 135 | // new set of options |
136 | } else if ((*it).left(1) == "[") { | 136 | } else if ((*it).left(1) == "[") { |
137 | index = (*it).mid(1, 1).toInt(); | 137 | index = (*it).mid(1, 1).toInt(); |
138 | // switch current key to index | 138 | // switch current key to index |
139 | switch (index) { | 139 | switch (index) { |
140 | case 1: | 140 | case 1: |
141 | keyRadio0->setChecked(true); | 141 | keyRadio0->setChecked(true); |
142 | break; | 142 | break; |
143 | case 2: | 143 | case 2: |
144 | keyRadio1->setChecked(true); | 144 | keyRadio1->setChecked(true); |
145 | break; | 145 | break; |
146 | case 3: | 146 | case 3: |
147 | keyRadio2->setChecked(true); | 147 | keyRadio2->setChecked(true); |
148 | break; | 148 | break; |
149 | case 4: | 149 | case 4: |
150 | keyRadio3->setChecked(true); | 150 | keyRadio3->setChecked(true); |
151 | break; | 151 | break; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | // key | 154 | // key |
155 | key = (*it); | 155 | key = (*it); |
156 | } | 156 | } |
157 | if (! key.isNull()) { | 157 | if (! key.isNull()) { |
158 | if (enc == -1) | 158 | if (enc == -1) |
159 | enc = 1; | 159 | enc = 1; |
160 | QStringList::Iterator next = ++it; | 160 | QStringList::Iterator next = ++it; |
161 | if (it == keys.end()) { | 161 | if (it == keys.end()) { |
162 | break; | 162 | break; |
163 | } | 163 | } |
164 | if ((*(next)).left(1) == "[") { | 164 | if ((*(next)).left(1) == "[") { |
165 | // set key at index | 165 | // set key at index |
166 | index = (*(next)).mid(1, 1).toInt(); | 166 | index = (*(next)).mid(1, 1).toInt(); |
167 | } else { | 167 | } else { |
168 | index = 1; | 168 | index = 1; |
169 | } | 169 | } |
170 | switch (index) { | 170 | switch (index) { |
171 | case 1: | 171 | case 1: |
172 | keyLineEdit0->setText(key); | 172 | keyLineEdit0->setText(key); |
173 | break; | 173 | break; |
174 | case 2: | 174 | case 2: |
175 | keyLineEdit1->setText(key); | 175 | keyLineEdit1->setText(key); |
176 | break; | 176 | break; |
177 | case 3: | 177 | case 3: |
178 | keyLineEdit2->setText(key); | 178 | keyLineEdit2->setText(key); |
179 | break; | 179 | break; |
180 | case 4: | 180 | case 4: |
181 | keyLineEdit3->setText(key); | 181 | keyLineEdit3->setText(key); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | key = QString::null; | 184 | key = QString::null; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | if (enc == 1) { | 187 | if (enc == 1) { |
188 | wepEnabled->setChecked(true); | 188 | wepEnabled->setChecked(true); |
189 | } else { | 189 | } else { |
190 | wepEnabled->setChecked(false); | 190 | wepEnabled->setChecked(false); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Check to see if the current config is valid | 195 | * Check to see if the current config is valid |
196 | * Save interfaces | 196 | * Save interfaces |
197 | */ | 197 | */ |
198 | void WLANImp::accept() { | 198 | void WLANImp::accept() { |
199 | if (wepEnabled->isChecked()) { | 199 | if (wepEnabled->isChecked()) { |
200 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 200 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
201 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 201 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
202 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 202 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
203 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 203 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
204 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 204 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | if (essid->currentText().isEmpty()) { | 209 | if (essid->currentText().isEmpty()) { |
210 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 210 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | 213 | ||
214 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 214 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
215 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 215 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | 218 | ||
219 | // Try to save the interfaces settings. | 219 | // Try to save the interfaces settings. |
220 | writeOpts(); | 220 | writeOpts(); |
221 | 221 | ||
222 | // Close out the dialog | 222 | // Close out the dialog |
223 | // FIXME: QDialog::accept(); | 223 | // FIXME: QDialog::accept(); |
224 | } | 224 | } |
225 | 225 | ||
226 | void WLANImp::writeOpts() { | 226 | void WLANImp::writeOpts() { |
227 | // eh can't really do anything about it other then return. :-D | 227 | // eh can't really do anything about it other then return. :-D |
228 | if(!interfaces->isInterfaceSet()){ | 228 | if(!interfaces->isInterfaceSet()){ |
229 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 229 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
230 | return; | 230 | return; |