summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan/wlanimp2.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/wlan/wlanimp2.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index e7b842b..b988822 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -5,86 +5,86 @@
5#include <qfile.h> 5#include <qfile.h>
6#include <qdir.h> 6#include <qdir.h>
7#include <qtextstream.h> 7#include <qtextstream.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qlabel.h> 10#include <qlabel.h>
11#include <qspinbox.h> 11#include <qspinbox.h>
12#include <qradiobutton.h> 12#include <qradiobutton.h>
13#include <qcheckbox.h> 13#include <qcheckbox.h>
14#include <qtabwidget.h> 14#include <qtabwidget.h>
15#include <qcombobox.h> 15#include <qcombobox.h>
16 16
17#ifdef QWS 17#ifdef QWS
18 #include <opie/oprocess.h> 18 #include <opie/oprocess.h>
19#else 19#else
20 #define OProcess KProcess 20 #define OProcess KProcess
21 #include <kprocess.h> 21 #include <kprocess.h>
22#endif 22#endif
23 23
24#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 24#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
25#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" 25#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools"
26 26
27/** 27/**
28 * Constructor, read in the wireless.opts file for parsing later. 28 * Constructor, read in the wireless.opts file for parsing later.
29 */ 29 */
30WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) { 30WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) {
31 interfaces = new Interfaces; 31 interfaces = new Interfaces;
32 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); 32 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
33 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 33 tabWidget->insertTab(interfaceSetup, "TCP/IP");
34 34
35 // Check sanity - the existance of the wireless-tools if-pre-up script 35 // Check sanity - the existance of the wireless-tools if-pre-up script
36 QFile file(QString(PREUP)); 36 QFile file(QString(PREUP));
37 if (file.exists()) { 37 if (file.exists()) {
38 qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); 38 qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
39 } 39 }
40} 40}
41 41
42WLANImp::~WLANImp() { 42WLANImp::~WLANImp() {
43 delete interfaces; 43//FIXME: delete interfaces;
44} 44}
45 45
46/** 46/**
47 * Change the profile for both wireless settings and network settings. 47 * Change the profile for both wireless settings and network settings.
48 */ 48 */
49void WLANImp::setProfile(const QString &profile){ 49void WLANImp::setProfile(const QString &profile){
50 interfaceSetup->setProfile(profile); 50 interfaceSetup->setProfile(profile);
51 parseOpts(); 51 parseOpts();
52} 52}
53 53
54void WLANImp::parseOpts() { 54void WLANImp::parseOpts() {
55 bool error; 55 bool error;
56 QString opt; 56 QString opt;
57 57
58 if (! interfaces->isInterfaceSet()) 58 if (! interfaces->isInterfaceSet())
59 return; 59 return;
60 60
61 61
62 opt = interfaces->getInterfaceOption("wireless_essid", error); 62 opt = interfaces->getInterfaceOption("wireless_essid", error);
63 if(opt == "any" || opt == "off" || opt.isNull()){ 63 if(opt == "any" || opt == "off" || opt.isNull()){
64 essid->setEditText("any"); 64 essid->setEditText("any");
65 } else { 65 } else {
66 essid->setEditText(opt); 66 essid->setEditText(opt);
67 } 67 }
68 68
69 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 69 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
70 if (opt == "Auto") { 70 if (opt == "Auto") {
71 mode->setCurrentItem(0); 71 mode->setCurrentItem(0);
72 } else if (opt == "Ad-Hoc") { 72 } else if (opt == "Ad-Hoc") {
73 mode->setCurrentItem(2); 73 mode->setCurrentItem(2);
74 } else { 74 } else {
75 // Managed/Infrastructure mode 75 // Managed/Infrastructure mode
76 mode->setCurrentItem(1); 76 mode->setCurrentItem(1);
77 } 77 }
78 78
79 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); 79 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
80 if (! opt.isNull()) { 80 if (! opt.isNull()) {
81 specifyAp->setChecked(true); 81 specifyAp->setChecked(true);
82 macEdit->setText(opt); 82 macEdit->setText(opt);
83 } 83 }
84 84
85 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); 85 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
86 if (! opt.isNull()) { 86 if (! opt.isNull()) {
87 specifyChan->setChecked(true); 87 specifyChan->setChecked(true);
88 networkChannel->setValue(opt.toInt()); 88 networkChannel->setValue(opt.toInt());
89 } 89 }
90 90
@@ -123,33 +123,33 @@ void WLANImp::parseKeyStr(QString keystr) {
123 case 1: 123 case 1:
124 keyRadio0->setChecked(true); 124 keyRadio0->setChecked(true);
125 break; 125 break;
126 case 2: 126 case 2:
127 keyRadio1->setChecked(true); 127 keyRadio1->setChecked(true);
128 break; 128 break;
129 case 3: 129 case 3:
130 keyRadio2->setChecked(true); 130 keyRadio2->setChecked(true);
131 break; 131 break;
132 case 4: 132 case 4:
133 keyRadio3->setChecked(true); 133 keyRadio3->setChecked(true);
134 break; 134 break;
135 } 135 }
136 } else { 136 } else {
137 // key 137 // key
138 key = (*it); 138 key = (*it);
139 } 139 }
140 if (! key.isNull()) { 140 if (! key.isNull()) {
141 if (enc == -1) 141 if (enc == -1)
142 enc = 1; 142 enc = 1;
143 QStringList::Iterator next = ++it; 143 QStringList::Iterator next = ++it;
144 if (it == keys.end()) { 144 if (it == keys.end()) {
145 break; 145 break;
146 } 146 }
147 if ((*(next)).left(1) == "[") { 147 if ((*(next)).left(1) == "[") {
148 // set key at index 148 // set key at index
149 index = (*(next)).mid(1, 1).toInt(); 149 index = (*(next)).mid(1, 1).toInt();
150 } else { 150 } else {
151 index = 1; 151 index = 1;
152 } 152 }
153 switch (index) { 153 switch (index) {
154 case 1: 154 case 1:
155 keyLineEdit0->setText(key); 155 keyLineEdit0->setText(key);
@@ -178,36 +178,36 @@ void WLANImp::parseKeyStr(QString keystr) {
178 * Check to see if the current config is valid 178 * Check to see if the current config is valid
179 * Save interfaces 179 * Save interfaces
180 */ 180 */
181void WLANImp::accept() { 181void WLANImp::accept() {
182 if (wepEnabled->isChecked()) { 182 if (wepEnabled->isChecked()) {
183 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || 183 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
184 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || 184 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
185 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || 185 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
186 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { 186 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
187 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); 187 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
188 return; 188 return;
189 } 189 }
190 } 190 }
191 191
192 if (essid->currentText().isEmpty()) { 192 if (essid->currentText().isEmpty()) {
193 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); 193 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
194 return; 194 return;
195 } 195 }
196 196
197 if (specifyAp->isChecked() && macEdit->text().isEmpty()) { 197 if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
198 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); 198 QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
199 return; 199 return;
200 } 200 }
201 201
202 // Try to save the interfaces settings. 202 // Try to save the interfaces settings.
203 writeOpts(); 203 writeOpts();
204 204
205 // Close out the dialog 205 // Close out the dialog
206 QDialog::accept(); 206 QDialog::accept();
207} 207}
208 208
209void WLANImp::writeOpts() { 209void WLANImp::writeOpts() {
210 bool error = false; 210 bool error = false;
211 211
212 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); 212 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
213 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); 213 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());