summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings
authorkergoth <kergoth>2002-10-19 20:58:09 (UTC)
committer kergoth <kergoth>2002-10-19 20:58:09 (UTC)
commitd7449e1e0070a068c5e83366cb75b64142b71b89 (patch) (unidiff)
tree0049f8b29e274c2b973ac74ce8f8a93b8bc38a77 /noncore/settings/networksettings
parent8c9e2e893540c0a405637f10ac2f656df69991a7 (diff)
downloadopie-d7449e1e0070a068c5e83366cb75b64142b71b89.zip
opie-d7449e1e0070a068c5e83366cb75b64142b71b89.tar.gz
opie-d7449e1e0070a068c5e83366cb75b64142b71b89.tar.bz2
Cleaned up Config handling a bit.
Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp83
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.h10
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp3
3 files changed, 48 insertions, 48 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 517604f..3b0e0b7 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -13,39 +13,40 @@
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qspinbox.h> 14#include <qspinbox.h>
15#include <qradiobutton.h> 15#include <qradiobutton.h>
16#include <qcheckbox.h> 16#include <qcheckbox.h>
17#include <qregexp.h> 17#include <qregexp.h>
18 18
19WLANImp::WLANImp( Config &cfg, QWidget* parent, const char* name):WLAN(parent, name),config(cfg){ 19WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){
20 config = new Config("wireless");
20 readConfig(); 21 readConfig();
21} 22}
22 23
23void WLANImp::readConfig() 24void WLANImp::readConfig()
24{ 25{
25 qWarning( "WLANImp::readConfig() called." ); 26 qWarning( "WLANImp::readConfig() called." );
26 config.setGroup( "Properties" ); 27 config->setGroup( "Properties" );
27 QString ssid = config.readEntry( "SSID", "any" ); 28 QString ssid = config->readEntry( "SSID", "any" );
28 if( ssid == "any" || ssid == "ANY" ){ 29 if( ssid == "any" || ssid == "ANY" ){
29 essNon->setChecked( true ); 30 essNon->setChecked( true );
30 } else { 31 } else {
31 essSpecific->setChecked( true ); 32 essSpecific->setChecked( true );
32 essSpecificLineEdit->setText( ssid ); 33 essSpecificLineEdit->setText( ssid );
33 } 34 }
34 QString mode = config.readEntry( "Mode", "Managed" ); 35 QString mode = config->readEntry( "Mode", "Managed" );
35 if( mode == "adhoc" ) { 36 if( mode == "adhoc" ) {
36 network802->setChecked( true ); 37 network802->setChecked( true );
37 } else { 38 } else {
38 networkInfrastructure->setChecked( true ); 39 networkInfrastructure->setChecked( true );
39 } 40 }
40 networkChannel->setValue( config.readNumEntry( "CHANNEL", 1 ) ); 41 networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) );
41// config.readEntry( "RATE", "auto" ); 42// config->readEntry( "RATE", "auto" );
42 config.readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); 43 config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false );
43 config.readEntry( "AuthType", "opensystem" ); 44 config->readEntry( "AuthType", "opensystem" );
44 config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); 45 config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true );
45 int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); 46 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 );
46 switch( defaultkey ){ 47 switch( defaultkey ){
47 case 0: 48 case 0:
48 keyRadio0->setChecked( true ); 49 keyRadio0->setChecked( true );
49 break; 50 break;
50 case 1: 51 case 1:
51 keyRadio1->setChecked( true ); 52 keyRadio1->setChecked( true );
@@ -54,52 +55,52 @@ void WLANImp::readConfig()
54 keyRadio2->setChecked( true ); 55 keyRadio2->setChecked( true );
55 break; 56 break;
56 case 3: 57 case 3:
57 keyRadio3->setChecked( true ); 58 keyRadio3->setChecked( true );
58 break; 59 break;
59 } 60 }
60 keyLineEdit0->setText(config.readEntry( "dot11WEPDefaultKey0" )); 61 keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" ));
61 keyLineEdit1->setText(config.readEntry( "dot11WEPDefaultKey1" )); 62 keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" ));
62 keyLineEdit2->setText(config.readEntry( "dot11WEPDefaultKey2" )); 63 keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" ));
63 keyLineEdit3->setText(config.readEntry( "dot11WEPDefaultKey3" )); 64 keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" ));
64 return; 65 return;
65} 66}
66 67
67bool WLANImp::writeConfig() 68bool WLANImp::writeConfig()
68{ 69{
69 qWarning( "WLANImp::writeConfig() called." ); 70 qWarning( "WLANImp::writeConfig() called." );
70 config.setGroup( "Properties" ); 71 config->setGroup( "Properties" );
71 if( essNon->isChecked() ) { 72 if( essNon->isChecked() ) {
72 config.writeEntry( "SSID", "any" ); 73 config->writeEntry( "SSID", "any" );
73 } else { 74 } else {
74 config.writeEntry( "SSID", essSpecificLineEdit->text() ); 75 config->writeEntry( "SSID", essSpecificLineEdit->text() );
75 } 76 }
76 if( networkInfrastructure->isChecked() ){ 77 if( networkInfrastructure->isChecked() ){
77 config.writeEntry( "Mode", "Managed" ); 78 config->writeEntry( "Mode", "Managed" );
78 } else if( network802->isChecked() ){ 79 } else if( network802->isChecked() ){
79 config.writeEntry( "Mode", "adhoc" ); 80 config->writeEntry( "Mode", "adhoc" );
80 } 81 }
81 config.writeEntry( "CHANNEL", networkChannel->value() ); 82 config->writeEntry( "CHANNEL", networkChannel->value() );
82// config.readEntry( "RATE", "auto" ); 83// config->readEntry( "RATE", "auto" );
83 wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); 84 wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" );
84 authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); 85 authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" );
85 key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); 86 key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" );
86 if( keyRadio0->isChecked() ){ 87 if( keyRadio0->isChecked() ){
87 config.writeEntry( "dot11WEPDefaultKeyID", 0 ); 88 config->writeEntry( "dot11WEPDefaultKeyID", 0 );
88 } else if( keyRadio1->isChecked() ){ 89 } else if( keyRadio1->isChecked() ){
89 config.writeEntry( "dot11WEPDefaultKeyID", 1 ); 90 config->writeEntry( "dot11WEPDefaultKeyID", 1 );
90 } else if( keyRadio2->isChecked() ){ 91 } else if( keyRadio2->isChecked() ){
91 config.writeEntry( "dot11WEPDefaultKeyID", 2 ); 92 config->writeEntry( "dot11WEPDefaultKeyID", 2 );
92 } else if( keyRadio3->isChecked() ){ 93 } else if( keyRadio3->isChecked() ){
93 config.writeEntry( "dot11WEPDefaultKeyID", 3 ); 94 config->writeEntry( "dot11WEPDefaultKeyID", 3 );
94 } 95 }
95 config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); 96 config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() );
96 config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); 97 config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() );
97 config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); 98 config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() );
98 config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); 99 config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() );
99 return writeWirelessOpts( config ); 100 return writeWirelessOpts( );
100} 101}
101 102
102/** 103/**
103 */ 104 */
104void WLANImp::accept() 105void WLANImp::accept()
105{ 106{
@@ -110,13 +111,13 @@ void WLANImp::accept()
110void WLANImp::done ( int r ) 111void WLANImp::done ( int r )
111{ 112{
112 QDialog::done ( r ); 113 QDialog::done ( r );
113 close ( ); 114 close ( );
114} 115}
115 116
116bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) 117bool WLANImp::writeWirelessOpts( QString scheme )
117{ 118{
118 qWarning( "WLANImp::writeWirelessOpts entered." ); 119 qWarning( "WLANImp::writeWirelessOpts entered." );
119 QString prev = "/etc/pcmcia/wireless.opts"; 120 QString prev = "/etc/pcmcia/wireless.opts";
120 QFile prevFile(prev); 121 QFile prevFile(prev);
121 if ( !prevFile.open( IO_ReadOnly ) ) 122 if ( !prevFile.open( IO_ReadOnly ) )
122 return false; 123 return false;
@@ -128,13 +129,13 @@ bool WLANImp::writeWirelessOpts( Config &config, QString scheme )
128 129
129 bool retval = true; 130 bool retval = true;
130 131
131 QTextStream in( &prevFile ); 132 QTextStream in( &prevFile );
132 QTextStream out( &tmpFile ); 133 QTextStream out( &tmpFile );
133 134
134 config.setGroup("Properties"); 135 config->setGroup("Properties");
135 136
136 QString line; 137 QString line;
137 bool found=false; 138 bool found=false;
138 bool done=false; 139 bool done=false;
139 while ( !in.atEnd() ) { 140 while ( !in.atEnd() ) {
140 QString line = in.readLine(); 141 QString line = in.readLine();
@@ -156,22 +157,22 @@ bool WLANImp::writeWirelessOpts( Config &config, QString scheme )
156 // end - add new entry 157 // end - add new entry
157 // Not all fields have a GUI, but all are supported 158 // Not all fields have a GUI, but all are supported
158 // in the letwork configuration files. 159 // in the letwork configuration files.
159 static const char* txtfields[] = { 160 static const char* txtfields[] = {
160 0 161 0
161 }; 162 };
162 QString readmode = config.readEntry( "Mode", "Managed" ); 163 QString readmode = config->readEntry( "Mode", "Managed" );
163 QString mode; 164 QString mode;
164 if( readmode == "Managed" ){ 165 if( readmode == "Managed" ){
165 mode = readmode; 166 mode = readmode;
166 } else if( readmode == "adhoc" ){ 167 } else if( readmode == "adhoc" ){
167 mode = "Ad-Hoc"; 168 mode = "Ad-Hoc";
168 } 169 }
169 QString key; 170 QString key;
170 if( wepEnabled->isChecked() ){ 171 if( wepEnabled->isChecked() ){
171 int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); 172 int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 );
172 switch( defaultkey ){ 173 switch( defaultkey ){
173 case 0: 174 case 0:
174 key += keyLineEdit0->text(); 175 key += keyLineEdit0->text();
175 break; 176 break;
176 case 1: 177 case 1:
177 key += keyLineEdit1->text(); 178 key += keyLineEdit1->text();
@@ -180,26 +181,26 @@ bool WLANImp::writeWirelessOpts( Config &config, QString scheme )
180 key += keyLineEdit2->text(); 181 key += keyLineEdit2->text();
181 break; 182 break;
182 case 3: 183 case 3:
183 key += keyLineEdit3->text(); 184 key += keyLineEdit3->text();
184 break; 185 break;
185 } 186 }
186 if( config.readEntry( "AuthType", "opensystem" ) == "opensystem") 187 if( config->readEntry( "AuthType", "opensystem" ) == "opensystem")
187 key += " open"; 188 key += " open";
188 } 189 }
189 out << scheme << ",*,*,*)" << "\n" 190 out << scheme << ",*,*,*)" << "\n"
190 << " ESSID=" << Global::shellQuote( config.readEntry( "SSID", "any" ) ) << "\n" 191 << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n"
191 << " MODE=" << mode << "\n" 192 << " MODE=" << mode << "\n"
192 << " KEY=" << Global::shellQuote( key ) << "\n" 193 << " KEY=" << Global::shellQuote( key ) << "\n"
193 << " RATE=" << "auto" << "\n" 194 << " RATE=" << "auto" << "\n"
194 ; 195 ;
195 if( mode != "Managed" ) 196 if( mode != "Managed" )
196 out << " CHANNEL=" << config.readNumEntry( "CHANNEL", 1 ) << "\n"; 197 out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n";
197 const char** f = txtfields; 198 const char** f = txtfields;
198 while (*f) { 199 while (*f) {
199 out << " " << *f << "=" << config.readEntry(*f,"") << "\n"; 200 out << " " << *f << "=" << config->readEntry(*f,"") << "\n";
200 ++f; 201 ++f;
201 } 202 }
202 out << " ;;\n"; 203 out << " ;;\n";
203 done = true; 204 done = true;
204 } 205 }
205 } 206 }
diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h
index 8e355ce..79e931d 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.h
+++ b/noncore/settings/networksettings/wlan/wlanimp.h
@@ -1,27 +1,27 @@
1#ifndef WLANIMP_H 1#ifndef WLANIMP_H
2#define WLANIMP_H 2#define WLANIMP_H
3 3
4#include "wlan.h" 4#include "wlan.h"
5 5
6class Config; 6#include <qpe/config.h>
7 7
8class WLANImp : public WLAN { 8class WLANImp : public WLAN {
9 Q_OBJECT 9 Q_OBJECT
10 10
11public: 11public:
12 WLANImp( Config& cfg, QWidget* parent = 0, const char* name = 0); 12 WLANImp( QWidget* parent = 0, const char* name = 0);
13 13
14protected: 14protected:
15 void accept(); 15 void accept();
16 void done ( int r ); 16 void done ( int r );
17 17
18private: 18private:
19 void readConfig(); 19 void readConfig();
20 bool writeConfig(); 20 bool writeConfig();
21 bool writeWirelessOpts( Config &cfg, QString scheme = "*" ); 21 bool writeWirelessOpts( QString scheme = "*" );
22 bool writeWlanngOpts( Config &cfg, QString scheme = "*" ); 22 bool writeWlanngOpts( QString scheme = "*" );
23 Config& config; 23 Config* config;
24}; 24};
25 25
26#endif 26#endif
27 27
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index f12e608..cbb520d 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -60,14 +60,13 @@ bool WLANModule::isOwner(Interface *i){
60/** 60/**
61 * Create, set tabWiget and return the WLANConfigure Module 61 * Create, set tabWiget and return the WLANConfigure Module
62 * @param tabWidget a pointer to the tab widget that this configure has. 62 * @param tabWidget a pointer to the tab widget that this configure has.
63 * @return QWidget* pointer to the tab widget in this modules configure. 63 * @return QWidget* pointer to the tab widget in this modules configure.
64 */ 64 */
65QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){ 65QWidget *WLANModule::configure(Interface *i, QTabWidget **tabWidget){
66 Config *cfg = new Config("wireless config"); 66 WLANImp *wlanconfig = new WLANImp( );
67 WLANImp *wlanconfig = new WLANImp(*cfg);
68 (*tabWidget) = wlanconfig->tabWidget; 67 (*tabWidget) = wlanconfig->tabWidget;
69 return wlanconfig; 68 return wlanconfig;
70} 69}
71 70
72/** 71/**
73 * Create, set tabWiget and return the Information Module 72 * Create, set tabWiget and return the Information Module