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.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index d36a702..5cb78cf 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -23,193 +23,192 @@ using namespace Opie::Net;
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qspinbox.h> 28#include <qspinbox.h>
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37 37
38/* STD */ 38/* STD */
39#include <assert.h> 39#include <assert.h>
40#include <errno.h> 40#include <errno.h>
41#include <string.h> 41#include <string.h>
42 42
43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 43#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
44#define PREUP "/etc/network/if-pre-up.d/wireless-tools" 44#define PREUP "/etc/network/if-pre-up.d/wireless-tools"
45 45
46/** 46/**
47 * Constructor, read in the wireless.opts file for parsing later. 47 * Constructor, read in the wireless.opts file for parsing later.
48 */ 48 */
49WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { 49WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
50 interfaces = new Interfaces(); 50 interfaces = new Interfaces();
51 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); 51 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
52 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 52 tabWidget->insertTab(interfaceSetup, "TCP/IP");
53 53
54 // Check sanity - the existance of the wireless-tools if-pre-up script 54 // Check sanity - the existance of the wireless-tools if-pre-up script
55 QFile file(QString(PREUP)); 55 QFile file(QString(PREUP));
56 if (file.exists()) { 56 if (file.exists()) {
57 owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; 57 owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl;
58 } 58 }
59 59
60 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); 60 connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
61 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); 61 connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) );
62 netView->setColumnAlignment( col_chn, AlignCenter ); 62 netView->setColumnAlignment( col_chn, AlignCenter );
63 netView->setItemMargin( 3 ); 63 netView->setItemMargin( 3 );
64 netView->setAllColumnsShowFocus( true ); 64 netView->setAllColumnsShowFocus( true );
65 65
66} 66}
67 67
68WLANImp::~WLANImp() { 68WLANImp::~WLANImp() {
69//FIXME: delete interfaces; 69//FIXME: delete interfaces;
70} 70}
71 71
72/** 72/**
73 * Change the profile for both wireless settings and network settings. 73 * Change the profile for both wireless settings and network settings.
74 */ 74 */
75void WLANImp::setProfile(const QString &profile){ 75void WLANImp::setProfile(const QString &profile){
76 interfaceSetup->setProfile(profile); 76 interfaceSetup->setProfile(profile);
77 parseOpts(); 77 parseOpts();
78} 78}
79 79
80void WLANImp::parseOpts() { 80void WLANImp::parseOpts() {
81 bool error; 81 bool error;
82 QString opt; 82 QString opt;
83 83
84 if (! interfaces->isInterfaceSet()) 84 if (! interfaces->isInterfaceSet())
85 return; 85 return;
86 86
87 87
88 opt = interfaces->getInterfaceOption("wireless_essid", error); 88 opt = interfaces->getInterfaceOption("wireless_essid", error);
89 if(opt == "any" || opt == "off" || opt.isNull()){ 89 if(opt == "any" || opt == "off" || opt.isNull()){
90 essid->setEditText("any"); 90 essid->setEditText("any");
91 } else { 91 } else {
92 essid->setEditText(opt); 92 essid->setEditText(opt);
93 } 93 }
94 94
95 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 95 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
96 96
97 for ( int i = 0; i < mode->count(); i++) 97 for ( int i = 0; i < mode->count(); i++)
98 if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); 98 if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
99 99
100 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); 100 opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
101 if (! opt.isNull()) { 101 if (! opt.isNull()) {
102 specifyAp->setChecked(true); 102 specifyAp->setChecked(true);
103 macEdit->setText(opt); 103 macEdit->setText(opt);
104 } 104 }
105 105
106 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); 106 opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
107 if (! opt.isNull()) { 107 if (! opt.isNull()) {
108 specifyChan->setChecked(true); 108 specifyChan->setChecked(true);
109 networkChannel->setValue(opt.toInt()); 109 networkChannel->setValue(opt.toInt());
110 } 110 }
111 111
112 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); 112 opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
113 if (opt.isNull()) 113 if (opt.isNull())
114 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); 114 opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
115 parseKeyStr(opt); 115 parseKeyStr(opt);
116} 116}
117 117
118void WLANImp::parseKeyStr(QString keystr) { 118void WLANImp::parseKeyStr(QString keystr) {
119 int loc = 0;
120 int index = 1; 119 int index = 1;
121 QString key; 120 QString key;
122 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); 121 QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
123 int enc = -1; // encryption state 122 int enc = -1; // encryption state
124 123
125 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { 124 for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
126 if ((*it).left(3) == "off") { 125 if ((*it).left(3) == "off") {
127 // encryption disabled 126 // encryption disabled
128 enc = 0; 127 enc = 0;
129 } else if ((*it).left(2) == "on") { 128 } else if ((*it).left(2) == "on") {
130 // encryption enabled 129 // encryption enabled
131 enc = 1; 130 enc = 1;
132 } else if ((*it).left(4) == "open") { 131 } else if ((*it).left(4) == "open") {
133 // open mode, accept non encrypted packets 132 // open mode, accept non encrypted packets
134 acceptNonEnc->setChecked(true); 133 acceptNonEnc->setChecked(true);
135 } else if ((*it).left(10) == "restricted") { 134 } else if ((*it).left(10) == "restricted") {
136 // restricted mode, only accept encrypted packets 135 // restricted mode, only accept encrypted packets
137 rejectNonEnc->setChecked(true); 136 rejectNonEnc->setChecked(true);
138 } else if ((*it).left(3) == "key") { 137 } else if ((*it).left(3) == "key") {
139 // new set of options 138 // new set of options
140 } else if ((*it).left(1) == "[") { 139 } else if ((*it).left(1) == "[") {
141 index = (*it).mid(1, 1).toInt(); 140 index = (*it).mid(1, 1).toInt();
142 // switch current key to index 141 // switch current key to index
143 switch (index) { 142 switch (index) {
144 case 1: 143 case 1:
145 keyRadio0->setChecked(true); 144 keyRadio0->setChecked(true);
146 break; 145 break;
147 case 2: 146 case 2:
148 keyRadio1->setChecked(true); 147 keyRadio1->setChecked(true);
149 break; 148 break;
150 case 3: 149 case 3:
151 keyRadio2->setChecked(true); 150 keyRadio2->setChecked(true);
152 break; 151 break;
153 case 4: 152 case 4:
154 keyRadio3->setChecked(true); 153 keyRadio3->setChecked(true);
155 break; 154 break;
156 } 155 }
157 } else { 156 } else {
158 // key 157 // key
159 key = (*it); 158 key = (*it);
160 } 159 }
161 if (! key.isNull()) { 160 if (! key.isNull()) {
162 if (enc == -1) 161 if (enc == -1)
163 enc = 1; 162 enc = 1;
164 QStringList::Iterator next = ++it; 163 QStringList::Iterator next = ++it;
165 if (it == keys.end()) { 164 if (it == keys.end()) {
166 break; 165 break;
167 } 166 }
168 if ((*(next)).left(1) == "[") { 167 if ((*(next)).left(1) == "[") {
169 // set key at index 168 // set key at index
170 index = (*(next)).mid(1, 1).toInt(); 169 index = (*(next)).mid(1, 1).toInt();
171 } else { 170 } else {
172 index = 1; 171 index = 1;
173 } 172 }
174 switch (index) { 173 switch (index) {
175 case 1: 174 case 1:
176 keyLineEdit0->setText(key); 175 keyLineEdit0->setText(key);
177 break; 176 break;
178 case 2: 177 case 2:
179 keyLineEdit1->setText(key); 178 keyLineEdit1->setText(key);
180 break; 179 break;
181 case 3: 180 case 3:
182 keyLineEdit2->setText(key); 181 keyLineEdit2->setText(key);
183 break; 182 break;
184 case 4: 183 case 4:
185 keyLineEdit3->setText(key); 184 keyLineEdit3->setText(key);
186 break; 185 break;
187 } 186 }
188 key = QString::null; 187 key = QString::null;
189 } 188 }
190 } 189 }
191 if (enc == 1) { 190 if (enc == 1) {
192 wepEnabled->setChecked(true); 191 wepEnabled->setChecked(true);
193 } else { 192 } else {
194 wepEnabled->setChecked(false); 193 wepEnabled->setChecked(false);
195 } 194 }
196} 195}
197 196
198/** 197/**
199 * Check to see if the current config is valid 198 * Check to see if the current config is valid
200 * Save interfaces 199 * Save interfaces
201 */ 200 */
202void WLANImp::accept() { 201void WLANImp::accept() {
203 if (wepEnabled->isChecked()) { 202 if (wepEnabled->isChecked()) {
204 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || 203 if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
205 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || 204 (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
206 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || 205 (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
207 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { 206 (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
208 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); 207 QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
209 return; 208 return;
210 } 209 }
211 } 210 }
212 211
213 if (essid->currentText().isEmpty()) { 212 if (essid->currentText().isEmpty()) {
214 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); 213 QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
215 return; 214 return;