summaryrefslogtreecommitdiff
authordrw <drw>2004-02-22 17:06:57 (UTC)
committer drw <drw>2004-02-22 17:06:57 (UTC)
commit68bd0ee2c7806b8fb35caf796e1d623e3d1f6011 (patch) (unidiff)
treebaee9d67d1134d1af933dfc21867c2607103813e
parenta607c211c7ad47f1083fa820da5632a1d2110e44 (diff)
downloadopie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.zip
opie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.tar.gz
opie-68bd0ee2c7806b8fb35caf796e1d623e3d1f6011.tar.bz2
Network Settings: libopie->libopie2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/config.in4
-rw-r--r--noncore/settings/networksettings/interfaces/.cvsignore3
-rw-r--r--noncore/settings/networksettings/interfaces/config.in2
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp6
-rw-r--r--noncore/settings/networksettings/main.cpp2
-rw-r--r--noncore/settings/networksettings/networksettings.pro2
-rw-r--r--noncore/settings/networksettings/opie-networksettings.control2
-rw-r--r--noncore/settings/networksettings/wlan/.cvsignore2
-rw-r--r--noncore/settings/networksettings/wlan/config.in4
-rw-r--r--noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp96
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp18
12 files changed, 74 insertions, 71 deletions
diff --git a/noncore/settings/networksettings/config.in b/noncore/settings/networksettings/config.in
index 4965a6e..e23e96a 100644
--- a/noncore/settings/networksettings/config.in
+++ b/noncore/settings/networksettings/config.in
@@ -1,13 +1,13 @@
1config NETWORKSETUP 1config NETWORKSETUP
2 boolean "opie-networksettings (TCP/IP network settings)" 2 boolean "opie-networksettings (TCP/IP network settings)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2NET 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2NET
5 5
6config NETWORKSETUP-CORE 6config NETWORKSETUP-CORE
7 boolean 7 boolean
8 default "y" if NETWORKSETUP 8 default "y" if NETWORKSETUP
9 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && INTERFACES 9 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && NETWORKSETUP && INTERFACES
10 10
11 source noncore/settings/networksettings/ppp/config.in 11 source noncore/settings/networksettings/ppp/config.in
12 source noncore/settings/networksettings/wlan/config.in 12 source noncore/settings/networksettings/wlan/config.in
13 source noncore/settings/networksettings/interfaces/config.in 13 source noncore/settings/networksettings/interfaces/config.in
diff --git a/noncore/settings/networksettings/interfaces/.cvsignore b/noncore/settings/networksettings/interfaces/.cvsignore
index 1655b12..0b2d203 100644
--- a/noncore/settings/networksettings/interfaces/.cvsignore
+++ b/noncore/settings/networksettings/interfaces/.cvsignore
@@ -1,11 +1,12 @@
1
2Makefile 1Makefile
3Makefile.in 2Makefile.in
4interfaceadvanced.cpp 3interfaceadvanced.cpp
5interfaceadvanced.h 4interfaceadvanced.h
6interfaceinformation.cpp 5interfaceinformation.cpp
7interfaceinformation.h 6interfaceinformation.h
8interfacesetup.cpp 7interfacesetup.cpp
9interfacesetup.h 8interfacesetup.h
10lib*.so* 9lib*.so*
11moc* 10moc*
11.moc
12.obj \ No newline at end of file
diff --git a/noncore/settings/networksettings/interfaces/config.in b/noncore/settings/networksettings/interfaces/config.in
index 6c21aeb..d84cd24 100644
--- a/noncore/settings/networksettings/interfaces/config.in
+++ b/noncore/settings/networksettings/interfaces/config.in
@@ -1,4 +1,4 @@
1 config INTERFACES 1 config INTERFACES
2 boolean 2 boolean
3 default "y" if NETWORKSETUP 3 default "y" if NETWORKSETUP
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index 78466d0..ab0e4cc 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -1,206 +1,206 @@
1#include "interfacesetupimp.h" 1#include "interfacesetupimp.h"
2#include "interface.h" 2#include "interface.h"
3 3
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qspinbox.h> 6#include <qspinbox.h>
7#include <qgroupbox.h> 7#include <qgroupbox.h>
8#include <qlabel.h> 8#include <qlabel.h>
9 9
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11 11
12#include <opie/oprocess.h> 12#include <opie/oprocess.h>
13 13
14#ifdef QWS 14#ifdef QWS
15#include <opie/owait.h> 15#include <opie2/owait.h>
16#include <qpe/global.h> 16#include <qpe/global.h>
17#include <qapplication.h> 17#include <qapplication.h>
18#endif 18#endif
19 19
20#define DNSSCRIPT "changedns" 20#define DNSSCRIPT "changedns"
21 21
22/** 22/**
23 * Constuctor. Set up the connection. A profile must be set. 23 * Constuctor. Set up the connection. A profile must be set.
24 */ 24 */
25InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ 25InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){
26 if (j == 0) { 26 if (j == 0) {
27 delInterfaces = true; 27 delInterfaces = true;
28 interfaces = new Interfaces; 28 interfaces = new Interfaces;
29 } 29 }
30} 30}
31 31
32/** 32/**
33 * Destructor 33 * Destructor
34 */ 34 */
35InterfaceSetupImp::~InterfaceSetupImp(){ 35InterfaceSetupImp::~InterfaceSetupImp(){
36 if(delInterfaces) { 36 if(delInterfaces) {
37 delete interfaces; 37 delete interfaces;
38 } 38 }
39} 39}
40 40
41/** 41/**
42 * Save the current settings, then write out the interfaces file and close. 42 * Save the current settings, then write out the interfaces file and close.
43 */ 43 */
44bool InterfaceSetupImp::saveChanges(){ 44bool InterfaceSetupImp::saveChanges(){
45 bool error; 45 bool error;
46 QString iface = interfaces->getInterfaceName(error); 46 QString iface = interfaces->getInterfaceName(error);
47 qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); 47 qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() );
48 if(!saveSettings()) 48 if(!saveSettings())
49 return false; 49 return false;
50 50
51 interfaces->write(); 51 interfaces->write();
52 52
53 if (interface->getStatus()) { 53 if (interface->getStatus()) {
54 QString ifup; 54 QString ifup;
55 ifup += "ifdown "; 55 ifup += "ifdown ";
56 ifup += iface; 56 ifup += iface;
57 ifup += "; ifup "; 57 ifup += "; ifup ";
58 ifup += iface; 58 ifup += iface;
59 ifup += ";"; 59 ifup += ";";
60 60
61 OProcess restart; 61 OProcess restart;
62 restart << "sh"; 62 restart << "sh";
63 restart << "-c"; 63 restart << "-c";
64 restart << ifup; 64 restart << ifup;
65 65
66 OWait *owait = new OWait(); 66 OWait *owait = new OWait();
67 Global::statusMessage( tr( "Restarting interface" ) ); 67 Global::statusMessage( tr( "Restarting interface" ) );
68 68
69 owait->show(); 69 owait->show();
70 qApp->processEvents(); 70 qApp->processEvents();
71 71
72 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { 72 if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) {
73 qWarning("unstable to spawn ifdown/ifup"); 73 qWarning("unstable to spawn ifdown/ifup");
74 } 74 }
75 75
76 owait->hide(); 76 owait->hide();
77 delete owait; 77 delete owait;
78 78
79 interface->refresh(); 79 interface->refresh();
80 } 80 }
81 return true; 81 return true;
82} 82}
83 83
84/** 84/**
85 * Save the settings for the current Interface. 85 * Save the settings for the current Interface.
86 * @return bool true if successful, false otherwise 86 * @return bool true if successful, false otherwise
87 */ 87 */
88bool InterfaceSetupImp::saveSettings(){ 88bool InterfaceSetupImp::saveSettings(){
89 // eh can't really do anything about it other then return. :-D 89 // eh can't really do anything about it other then return. :-D
90 if(!interfaces->isInterfaceSet()) 90 if(!interfaces->isInterfaceSet())
91 return true; 91 return true;
92 92
93 bool error = false; 93 bool error = false;
94 // Loopback case 94 // Loopback case
95 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 95 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
96 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 96 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
97 return true; 97 return true;
98 } 98 }
99 99
100 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 100 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
101 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); 101 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
102 return false; 102 return false;
103 } 103 }
104 // DHCP 104 // DHCP
105 if(dhcpCheckBox->isChecked()) { 105 if(dhcpCheckBox->isChecked()) {
106 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 106 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
107 interfaces->removeInterfaceOption("address"); 107 interfaces->removeInterfaceOption("address");
108 interfaces->removeInterfaceOption("netmask"); 108 interfaces->removeInterfaceOption("netmask");
109 interfaces->removeInterfaceOption("gateway"); 109 interfaces->removeInterfaceOption("gateway");
110 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 110 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
111 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); 111 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r ");
112 } else{ 112 } else{
113 interfaces->setInterfaceMethod("static"); 113 interfaces->setInterfaceMethod("static");
114 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 114 interfaces->setInterfaceOption("address", ipAddressEdit->text());
115 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 115 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
116 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 116 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
117 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 117 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
118 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 118 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
119 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 119 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
120 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 120 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
121 }else{ 121 }else{
122 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); 122 interfaces->removeInterfaceOption("up "DNSSCRIPT" -a ");
123 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); 123 interfaces->removeInterfaceOption("down "DNSSCRIPT" -r");
124 } 124 }
125 } 125 }
126 126
127 // IP Information 127 // IP Information
128 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 128 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
129 return true; 129 return true;
130} 130}
131 131
132/** 132/**
133 * The Profile has changed. 133 * The Profile has changed.
134 * @param QString profile the new profile. 134 * @param QString profile the new profile.
135 */ 135 */
136void InterfaceSetupImp::setProfile(const QString &profile){ 136void InterfaceSetupImp::setProfile(const QString &profile){
137 /* 137 /*
138 bool error = false; 138 bool error = false;
139 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 139 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
140 staticGroupBox->hide(); 140 staticGroupBox->hide();
141 dhcpCheckBox->hide(); 141 dhcpCheckBox->hide();
142 leaseTime->hide(); 142 leaseTime->hide();
143 leaseHoursLabel->hide(); 143 leaseHoursLabel->hide();
144 } 144 }
145 */ 145 */
146 146
147 QString newInterfaceName = interface->getInterfaceName(); 147 QString newInterfaceName = interface->getInterfaceName();
148 if(profile.length() > 0) 148 if(profile.length() > 0)
149 newInterfaceName += "_" + profile; 149 newInterfaceName += "_" + profile;
150 // See if we have to make a interface. 150 // See if we have to make a interface.
151 if(!interfaces->setInterface(newInterfaceName)){ 151 if(!interfaces->setInterface(newInterfaceName)){
152 // Add making for this new interface if need too 152 // Add making for this new interface if need too
153 if(profile != ""){ 153 if(profile != ""){
154 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); 154 interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName);
155 if(!interfaces->setMapping(interface->getInterfaceName())){ 155 if(!interfaces->setMapping(interface->getInterfaceName())){
156 interfaces->addMapping(interface->getInterfaceName()); 156 interfaces->addMapping(interface->getInterfaceName());
157 if(!interfaces->setMapping(interface->getInterfaceName())){ 157 if(!interfaces->setMapping(interface->getInterfaceName())){
158 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); 158 qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface.");
159 return; 159 return;
160 } 160 }
161 } 161 }
162 interfaces->setMap("map", newInterfaceName); 162 interfaces->setMap("map", newInterfaceName);
163 interfaces->setScript("getprofile.sh"); 163 interfaces->setScript("getprofile.sh");
164 } 164 }
165 else{ 165 else{
166 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); 166 interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP);
167 if(!interfaces->setInterface(newInterfaceName)){ 167 if(!interfaces->setInterface(newInterfaceName)){
168 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); 168 qDebug("InterfaceSetupImp: Added interface, but still can't setInterface.");
169 return; 169 return;
170 } 170 }
171 } 171 }
172 } 172 }
173 173
174 // We must have a valid interface to get this far so read some settings. 174 // We must have a valid interface to get this far so read some settings.
175 175
176 // DHCP 176 // DHCP
177 bool error = false; 177 bool error = false;
178 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 178 if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP)
179 dhcpCheckBox->setChecked(true); 179 dhcpCheckBox->setChecked(true);
180 else 180 else
181 dhcpCheckBox->setChecked(false); 181 dhcpCheckBox->setChecked(false);
182 182
183 // IP Information 183 // IP Information
184 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); 184 autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName()));
185 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); 185 QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error);
186 qDebug("dns >%s<",dns.latin1()); 186 qDebug("dns >%s<",dns.latin1());
187 if(dns.contains(" ")){ 187 if(dns.contains(" ")){
188 firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); 188 firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
189 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); 189 secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
190 }else firstDNSLineEdit->setText(dns); 190 }else firstDNSLineEdit->setText(dns);
191 191
192 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); 192 ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
193 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); 193 subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
194 if (subnetMaskEdit->text().isEmpty()) 194 if (subnetMaskEdit->text().isEmpty())
195 subnetMaskEdit->setText( "255.255.255.0" ); 195 subnetMaskEdit->setText( "255.255.255.0" );
196 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); 196 gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
197 197
198 198
199 199
200 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); 200 qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
201 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); 201 qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
202 202
203} 203}
204 204
205// interfacesetup.cpp 205// interfacesetup.cpp
206 206
diff --git a/noncore/settings/networksettings/main.cpp b/noncore/settings/networksettings/main.cpp
index 5d275ac..bc11ab4 100644
--- a/noncore/settings/networksettings/main.cpp
+++ b/noncore/settings/networksettings/main.cpp
@@ -1,6 +1,6 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include <opie/oapplicationfactory.h> 2#include <opie2/oapplicationfactory.h>
3 3
4OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> ) 4OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> )
5 5
6 6
diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro
index 0615ea4..5db2d6b 100644
--- a/noncore/settings/networksettings/networksettings.pro
+++ b/noncore/settings/networksettings/networksettings.pro
@@ -1,12 +1,12 @@
1CONFIG = qt warn_on debug quick-app 1CONFIG = qt warn_on debug quick-app
2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h 2HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h
3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp 3SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp
4INCLUDEPATH += $(OPIEDIR)/include interfaces/ 4INCLUDEPATH += $(OPIEDIR)/include interfaces/
5DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/ 5DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/
6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopie 6LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2
7INTERFACES = mainwindow.ui addconnection.ui 7INTERFACES = mainwindow.ui addconnection.ui
8TARGET = networksettings 8TARGET = networksettings
9 9
10 10
11 11
12include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/opie-networksettings.control b/noncore/settings/networksettings/opie-networksettings.control
index 25e1e26..fbbddca 100644
--- a/noncore/settings/networksettings/opie-networksettings.control
+++ b/noncore/settings/networksettings/opie-networksettings.control
@@ -1,10 +1,10 @@
1Package: opie-networksettings 1Package: opie-networksettings
2Files: plugins/application/libnetworksettings.so* bin/networksettings apps/Settings/networksettings.desktop pics/networksettings/* pics/Network/PPPConnect.png lib/libinterfaces.so* root/usr/bin/changedns bin/getprofile 2Files: plugins/application/libnetworksettings.so* bin/networksettings apps/Settings/networksettings.desktop pics/networksettings/* pics/Network/PPPConnect.png lib/libinterfaces.so* root/usr/bin/changedns bin/getprofile
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 5Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopiecore2, libopienet2 7Depends: task-opie-minimal, libopiecore2, libopieui2, libopienet2
8Description: Network settings. 8Description: Network settings.
9Replaces: opie-networksetup 9Replaces: opie-networksetup
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings/wlan/.cvsignore b/noncore/settings/networksettings/wlan/.cvsignore
index 7073cac..ae45698 100644
--- a/noncore/settings/networksettings/wlan/.cvsignore
+++ b/noncore/settings/networksettings/wlan/.cvsignore
@@ -1,7 +1,9 @@
1Makefile 1Makefile
2Makefile.in 2Makefile.in
3info.cpp 3info.cpp
4info.h 4info.h
5moc_* 5moc_*
6wlan.cpp 6wlan.cpp
7wlan.h 7wlan.h
8.moc
9.obj
diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in
index e459788..97fa468 100644
--- a/noncore/settings/networksettings/wlan/config.in
+++ b/noncore/settings/networksettings/wlan/config.in
@@ -1,6 +1,6 @@
1 config WLAN 1 config WLAN
2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)" 2 boolean "opie-networksettingsplugin-wlan (wireless LAN module)"
3 default "n" if NETWORKSETUP 3 default "n" if NETWORKSETUP
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET
5 #comment "opie-networksettingsplugin-wlan needs libopie, libopie2net and networksetup" 5 #comment "opie-networksettingsplugin-wlan needs libopie2ui, libopie2net and networksetup"
6 #depends !( LIBOPIE2NET && LIBOPIE && NETWORKSETUP) \ No newline at end of file 6 #depends !( LIBOPIE2NET && LIBOPIE && NETWORKSETUP) \ No newline at end of file
diff --git a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
index 1147621..f4f20b1 100644
--- a/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
+++ b/noncore/settings/networksettings/wlan/opie-networksettingsplugin-wlan.control
@@ -1,9 +1,9 @@
1Package: opie-networksettingsplugin-wlan 1Package: opie-networksettingsplugin-wlan
2Files: plugins/networksettings/libwlan.so* 2Files: plugins/networksettings/libwlan.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Patrick S. Vogt <tille@handhelds.org> 5Maintainer: Patrick S. Vogt <tille@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings, libopienet2 7Depends: opie-networksettings, libopiecore2, libopienet2
8Description: Network settings wavelan plugin. 8Description: Network settings wavelan plugin.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 719be1b..95f4abe 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -1,244 +1,244 @@
1#include "wlanimp.h" 1#include "wlanimp.h"
2#include "interfacesetupimp.h" 2#include "interfacesetupimp.h"
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qspinbox.h> 10#include <qspinbox.h>
11#include <qradiobutton.h> 11#include <qradiobutton.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qtabwidget.h> 13#include <qtabwidget.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15 15
16#ifdef QWS 16#ifdef QWS
17 #include <opie/oprocess.h> 17 #include <opie2/oprocess.h>
18#else 18#else
19 #define OProcess KProcess 19 #define OProcess KProcess
20 #include <kprocess.h> 20 #include <kprocess.h>
21#endif 21#endif
22 22
23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
24 24
25/** 25/**
26 * Constructor, read in the wireless.opts file for parsing later. 26 * Constructor, read in the wireless.opts file for parsing later.
27 */ 27 */
28WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { 28WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
29 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); 29 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
30 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 30 tabWidget->insertTab(interfaceSetup, "TCP/IP");
31 31
32 // Read in the config file. 32 // Read in the config file.
33 QString wlanFile = WIRELESS_OPTS; 33 QString wlanFile = WIRELESS_OPTS;
34 QFile file(wlanFile); 34 QFile file(wlanFile);
35 if (file.open(IO_ReadOnly)){ 35 if (file.open(IO_ReadOnly)){
36 QTextStream stream( &file ); 36 QTextStream stream( &file );
37 QString line = ""; 37 QString line = "";
38 while ( !stream.eof() ) { 38 while ( !stream.eof() ) {
39 line += stream.readLine(); 39 line += stream.readLine();
40 line += "\n"; 40 line += "\n";
41 } 41 }
42 file.close(); 42 file.close();
43 settingsFileText = QStringList::split("\n", line, true); 43 settingsFileText = QStringList::split("\n", line, true);
44 parseSettingFile(); 44 parseSettingFile();
45 } 45 }
46 else 46 else
47 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 47 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
48 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); 48 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
49} 49}
50 50
51void WLANImp::typeChanged(int mod){ 51void WLANImp::typeChanged(int mod){
52 networkChannel->setEnabled(mod); 52 networkChannel->setEnabled(mod);
53 channelLabel->setEnabled(mod); 53 channelLabel->setEnabled(mod);
54} 54}
55 55
56/** 56/**
57 * Change the profile for both wireless settings and network settings. 57 * Change the profile for both wireless settings and network settings.
58 */ 58 */
59void WLANImp::setProfile(const QString &profile){ 59void WLANImp::setProfile(const QString &profile){
60 interfaceSetup->setProfile(profile); 60 interfaceSetup->setProfile(profile);
61 parseSettingFile(); 61 parseSettingFile();
62} 62}
63 63
64/** 64/**
65 * Parses the settings file that was read in and gets any setting from it. 65 * Parses the settings file that was read in and gets any setting from it.
66 */ 66 */
67void WLANImp::parseSettingFile(){ 67void WLANImp::parseSettingFile(){
68 bool foundCase = false; 68 bool foundCase = false;
69 bool found = false; 69 bool found = false;
70 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 70 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
71 QString line = (*it).simplifyWhiteSpace(); 71 QString line = (*it).simplifyWhiteSpace();
72 if(line.contains("case")) 72 if(line.contains("case"))
73 foundCase = true; 73 foundCase = true;
74 // See if we found our scheme to write or the sceme couldn't be found 74 // See if we found our scheme to write or the sceme couldn't be found
75 if((foundCase && line.contains("esac")) || 75 if((foundCase && line.contains("esac")) ||
76 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) 76 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
77 found = true; 77 found = true;
78 78
79 if(line.contains(";;")) 79 if(line.contains(";;"))
80 found = false; 80 found = false;
81 if(found){ 81 if(found){
82 // write out scheme 82 // write out scheme
83 if(line.contains("ESSID=")){ 83 if(line.contains("ESSID=")){
84 QString id = line.mid(line.find("ESSID=")+6, line.length()); 84 QString id = line.mid(line.find("ESSID=")+6, line.length());
85 if(id == "any"){ 85 if(id == "any"){
86 essAny->setChecked(false); 86 essAny->setChecked(false);
87 }else{ 87 }else{
88 essAny->setChecked(true); 88 essAny->setChecked(true);
89 essSpecificLineEdit->setText(id); 89 essSpecificLineEdit->setText(id);
90 } 90 }
91 } 91 }
92 if(line.contains("MODE=")){ 92 if(line.contains("MODE=")){
93 QString mode = line.mid(line.find("MODE=")+5, line.length()); 93 QString mode = line.mid(line.find("MODE=")+5, line.length());
94 if(mode == "Managed"){ 94 if(mode == "Managed"){
95 networkType->setCurrentItem(0); 95 networkType->setCurrentItem(0);
96 channelLabel->setEnabled(false); 96 channelLabel->setEnabled(false);
97 networkChannel->setEnabled(false); 97 networkChannel->setEnabled(false);
98 } 98 }
99 else{ 99 else{
100 networkType->setCurrentItem(1); 100 networkType->setCurrentItem(1);
101 networkChannel->setEnabled(true); 101 networkChannel->setEnabled(true);
102 channelLabel->setEnabled(true); 102 channelLabel->setEnabled(true);
103 } 103 }
104 } 104 }
105 if(line.contains("#KEY0=")) 105 if(line.contains("#KEY0="))
106 keyLineEdit0->setText(line.mid(6, line.length())); 106 keyLineEdit0->setText(line.mid(6, line.length()));
107 if(line.contains("#KEY1=")) 107 if(line.contains("#KEY1="))
108 keyLineEdit1->setText(line.mid(6, line.length())); 108 keyLineEdit1->setText(line.mid(6, line.length()));
109 if(line.contains("#KEY2=")) 109 if(line.contains("#KEY2="))
110 keyLineEdit2->setText(line.mid(6, line.length())); 110 keyLineEdit2->setText(line.mid(6, line.length()));
111 if(line.contains("#KEY3=")) 111 if(line.contains("#KEY3="))
112 keyLineEdit3->setText(line.mid(6, line.length())); 112 keyLineEdit3->setText(line.mid(6, line.length()));
113 113
114 if(line.contains("KEY=")){ 114 if(line.contains("KEY=")){
115 wepEnabled->setChecked(true); 115 wepEnabled->setChecked(true);
116 QString key; 116 QString key;
117 if(line.right(5) == (" open")){ 117 if(line.right(5) == (" open")){
118 key = line.mid(4, line.length()-5); 118 key = line.mid(4, line.length()-5);
119 authOpen->setChecked(true); 119 authOpen->setChecked(true);
120 authShared->setChecked(false); 120 authShared->setChecked(false);
121 } 121 }
122 else{ 122 else{
123 authOpen->setChecked(false); 123 authOpen->setChecked(false);
124 authShared->setChecked(true); 124 authShared->setChecked(true);
125 key = line.mid(4, line.length()); 125 key = line.mid(4, line.length());
126 } 126 }
127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
131 } 131 }
132 if(line.contains("CHANNEL=")){ 132 if(line.contains("CHANNEL=")){
133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
134 } 134 }
135 } 135 }
136 } 136 }
137} 137}
138 138
139/** 139/**
140 * Saves settings to the wireless.opts file using the current profile 140 * Saves settings to the wireless.opts file using the current profile
141 */ 141 */
142void WLANImp::changeAndSaveSettingFile(){ 142void WLANImp::changeAndSaveSettingFile(){
143 QString wlanFile = WIRELESS_OPTS; 143 QString wlanFile = WIRELESS_OPTS;
144 QFile::remove(wlanFile); 144 QFile::remove(wlanFile);
145 QFile file(wlanFile); 145 QFile file(wlanFile);
146 146
147 if (!file.open(IO_ReadWrite)){ 147 if (!file.open(IO_ReadWrite)){
148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
149 return; 149 return;
150 } 150 }
151 151
152 QTextStream stream( &file ); 152 QTextStream stream( &file );
153 bool foundCase = false; 153 bool foundCase = false;
154 bool found = false; 154 bool found = false;
155 bool output = true; 155 bool output = true;
156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
157 QString line = (*it).simplifyWhiteSpace(); 157 QString line = (*it).simplifyWhiteSpace();
158 if(line.contains("case")) 158 if(line.contains("case"))
159 foundCase = true; 159 foundCase = true;
160 // See if we found our scheme to write or the sceme couldn't be found 160 // See if we found our scheme to write or the sceme couldn't be found
161 if((foundCase && line.contains("esac") && !found) || 161 if((foundCase && line.contains("esac") && !found) ||
162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
163 // write out scheme 163 // write out scheme
164 found = true; 164 found = true;
165 output = false; 165 output = false;
166 166
167 if(!line.contains("esac")) 167 if(!line.contains("esac"))
168 stream << line << "\n"; 168 stream << line << "\n";
169 if(!essAny->isChecked() == true){ 169 if(!essAny->isChecked() == true){
170 stream << "\tESSID=any\n"; 170 stream << "\tESSID=any\n";
171 stream << "\tMODE=Managed\n"; 171 stream << "\tMODE=Managed\n";
172 } 172 }
173 else{ 173 else{
174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; 174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n';
175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; 175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n';
176 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 176 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
177 } 177 }
178 178
179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; 179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n";
180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; 180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n";
181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; 181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n";
182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; 182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n";
183 183
184 if(wepEnabled->isChecked()){ 184 if(wepEnabled->isChecked()){
185 stream << "\tKEY=\""; 185 stream << "\tKEY=\"";
186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
190 if(authOpen->isChecked()) 190 if(authOpen->isChecked())
191 stream << " open"; 191 stream << " open";
192 else 192 else
193 stream << " restricted"; 193 stream << " restricted";
194 stream << "\"\n"; 194 stream << "\"\n";
195 } 195 }
196 stream << "\tRATE=auto\n"; 196 stream << "\tRATE=auto\n";
197 if(line.contains("esac")) 197 if(line.contains("esac"))
198 stream << line << "\n"; 198 stream << line << "\n";
199 } 199 }
200 if(line.contains(";;")) 200 if(line.contains(";;"))
201 output = true; 201 output = true;
202 if(output && (*it).length() ) 202 if(output && (*it).length() )
203 stream << (*it) << '\n'; 203 stream << (*it) << '\n';
204 } 204 }
205 file.close(); 205 file.close();
206} 206}
207 207
208/** 208/**
209 * Check to see if the current config is valid 209 * Check to see if the current config is valid
210 * Save wireless.opts, save interfaces 210 * Save wireless.opts, save interfaces
211 */ 211 */
212void WLANImp::accept(){ 212void WLANImp::accept(){
213 if(wepEnabled->isChecked()){ 213 if(wepEnabled->isChecked()){
214 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ 214 if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){
215 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); 215 QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok);
216 return; 216 return;
217 } 217 }
218 } 218 }
219 219
220 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){ 220 if(essAny->isChecked() && essSpecificLineEdit->text().isEmpty()){
221 QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok); 221 QMessageBox::information(this, "Error", "Please enter a SSID.", QMessageBox::Ok);
222 return; 222 return;
223 } 223 }
224 224
225 // Ok settings are good here, save 225 // Ok settings are good here, save
226 changeAndSaveSettingFile(); 226 changeAndSaveSettingFile();
227 227
228 // Try to save the interfaces settings. 228 // Try to save the interfaces settings.
229 if(!interfaceSetup->saveChanges()) 229 if(!interfaceSetup->saveChanges())
230 return; 230 return;
231 231
232 OProcess insert; 232 OProcess insert;
233 insert << "sh"; 233 insert << "sh";
234 insert << "-c"; 234 insert << "-c";
235 insert << "cardctl eject && cardctl insert"; 235 insert << "cardctl eject && cardctl insert";
236 236
237 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) { 237 if (!insert.start(OProcess::DontCare, OProcess::NoCommunication) ) {
238 qWarning("could not start cardctl"); 238 qWarning("could not start cardctl");
239 } 239 }
240 240
241 // Close out the dialog 241 // Close out the dialog
242 QDialog::accept(); 242 QDialog::accept();
243} 243}
244 244
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,278 +1,278 @@
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 */
45WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { 45WLANImp::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
64WLANImp::~WLANImp() { 64WLANImp::~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 */
71void WLANImp::setProfile(const QString &profile){ 71void WLANImp::setProfile(const QString &profile){
72 interfaceSetup->setProfile(profile); 72 interfaceSetup->setProfile(profile);
73 parseOpts(); 73 parseOpts();
74} 74}
75 75
76void WLANImp::parseOpts() { 76void WLANImp::parseOpts() {
77 bool error; 77 bool error;
78 QString opt; 78 QString opt;
79 79
80 if (! interfaces->isInterfaceSet()) 80 if (! interfaces->isInterfaceSet())
81 return; 81 return;
82 82
83 83
84 opt = interfaces->getInterfaceOption("wireless_essid", error); 84 opt = interfaces->getInterfaceOption("wireless_essid", error);
85 if(opt == "any" || opt == "off" || opt.isNull()){ 85 if(opt == "any" || opt == "off" || opt.isNull()){
86 essid->setEditText("any"); 86 essid->setEditText("any");
87 } else { 87 } else {
88 essid->setEditText(opt); 88 essid->setEditText(opt);
89 } 89 }
90 90
91 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); 91 opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
92 92
93 for ( int i = 0; i < mode->count(); i++) 93 for ( int i = 0; i < mode->count(); i++)
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
114void WLANImp::parseKeyStr(QString keystr) { 114void 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 */
198void WLANImp::accept() { 198void 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
226void WLANImp::writeOpts() { 226void 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;
231 } 231 }
232 bool error = false; 232 bool error = false;
233 233
234 qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); 234 qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
235 235
236 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); 236 if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
237 237
238 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); 238 interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
239 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); 239 interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
240 240
241 if (specifyAp->isChecked()) { 241 if (specifyAp->isChecked()) {
242 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); 242 interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
243 } else { 243 } else {
244 interfaces->removeInterfaceOption(QString("wireless_ap")); 244 interfaces->removeInterfaceOption(QString("wireless_ap"));
245 } 245 }
246 246
247 if (specifyChan->isChecked()) { 247 if (specifyChan->isChecked()) {
248 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); 248 interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
249 } else { 249 } else {
250 interfaces->removeInterfaceOption(QString("wireless_channel")); 250 interfaces->removeInterfaceOption(QString("wireless_channel"));
251 } 251 }
252 252
253 if (wepEnabled->isChecked()) { 253 if (wepEnabled->isChecked()) {
254 QStringList keyList; 254 QStringList keyList;
255 255
256 if (! keyLineEdit0->text().isNull()) { 256 if (! keyLineEdit0->text().isNull()) {
257 keyList += keyLineEdit0->text(); 257 keyList += keyLineEdit0->text();
258 keyList += "[1]"; 258 keyList += "[1]";
259 } //else 259 } //else
260 if (! keyLineEdit1->text().isNull()) { 260 if (! keyLineEdit1->text().isNull()) {
261 keyList += keyLineEdit1->text(); 261 keyList += keyLineEdit1->text();
262 keyList += "[2]"; 262 keyList += "[2]";
263 } //else 263 } //else
264 if (! keyLineEdit2->text().isNull()) { 264 if (! keyLineEdit2->text().isNull()) {
265 keyList += keyLineEdit2->text(); 265 keyList += keyLineEdit2->text();
266 keyList += "[3]"; 266 keyList += "[3]";
267 } //else 267 } //else
268 if (! keyLineEdit3->text().isNull()) { 268 if (! keyLineEdit3->text().isNull()) {
269 keyList += keyLineEdit3->text(); 269 keyList += keyLineEdit3->text();
270 keyList += "[4]"; 270 keyList += "[4]";
271 } 271 }
272 if (acceptNonEnc->isChecked()) { 272 if (acceptNonEnc->isChecked()) {
273 keyList += "open"; 273 keyList += "open";
274 } else { 274 } else {
275 keyList += "restricted"; 275 keyList += "restricted";
276 } 276 }
277 277
278 keyList += "key"; 278 keyList += "key";