-rw-r--r-- | noncore/net/networksetup/wlan/wlan.ui | 173 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 45 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.h | 3 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlan.ui | 173 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 45 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.h | 3 |
6 files changed, 212 insertions, 230 deletions
diff --git a/noncore/net/networksetup/wlan/wlan.ui b/noncore/net/networksetup/wlan/wlan.ui index 47d6db6..09593b3 100644 --- a/noncore/net/networksetup/wlan/wlan.ui +++ b/noncore/net/networksetup/wlan/wlan.ui @@ -1,39 +1,39 @@ <!DOCTYPE UI><UI> <class>WLAN</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>WLAN</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>237</width> - <height>286</height> + <width>239</width> + <height>277</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Wireless LAN Setting</string> </property> <property stdset="1"> <name>sizeGripEnabled</name> <bool>true</bool> </property> <property> <name>layoutMargin</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> @@ -44,192 +44,167 @@ <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>ConfigPage</cstring> </property> <attribute> <name>title</name> <string>WLAN General</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> - <class>QButtonGroup</class> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>essAny</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Sepecify Access Point</string> + </property> + </widget> + <widget> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup45</cstring> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> </property> <property stdset="1"> <name>title</name> - <string>ESS ID</string> + <string>Settings</string> </property> - <vbox> + <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget> - <class>QRadioButton</class> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>essNon</cstring> + <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> - <string>Non-Spec ESSID: "ANY"</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <string>ESS-ID</string> </property> </widget> - <widget> - <class>QRadioButton</class> + <widget row="1" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>essSpecific</cstring> + <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> - <string>Specific ESSID</string> + <string>Network Type</string> </property> </widget> - <widget> + <widget row="0" column="1" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>essSpecificLineEdit</cstring> </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> </widget> - </vbox> - </widget> - <widget> - <class>QButtonGroup</class> - <property stdset="1"> - <name>name</name> - <cstring>ButtonGroup46</cstring> - </property> - <property stdset="1"> - <name>title</name> - <string>Network Type</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>11</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget row="0" column="0" rowspan="1" colspan="3" > - <class>QRadioButton</class> + <widget row="1" column="1" rowspan="1" colspan="2" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Infrastructure</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Ad-Hoc</string> + </property> + </item> <property stdset="1"> <name>name</name> - <cstring>networkInfrastructure</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Infrastructure</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <cstring>networkType</cstring> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <cstring>channelLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Channel</string> </property> </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>QRadioButton</class> - <property stdset="1"> - <name>name</name> - <cstring>network802</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Ad-Hoc</string> - </property> - </widget> <widget row="2" column="1" > <class>QSpinBox</class> <property stdset="1"> <name>name</name> <cstring>networkChannel</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>maxValue</name> - <number>11</number> + <number>15</number> </property> <property stdset="1"> <name>minValue</name> <number>1</number> </property> <property stdset="1"> <name>value</name> <number>6</number> </property> </widget> <spacer row="2" column="2" > <property> <name>name</name> - <cstring>Spacer32</cstring> + <cstring>Spacer4</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </grid> </widget> <spacer> <property> <name>name</name> <cstring>Spacer31</cstring> </property> @@ -315,94 +290,110 @@ <string>Open System</string> </property> <property stdset="1"> <name>checked</name> <bool>true</bool> </property> </widget> <widget> <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>authShared</cstring> </property> <property stdset="1"> <name>text</name> <string>Shared Key</string> </property> </widget> </hbox> </widget> <widget> <class>QButtonGroup</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup44</cstring> + <cstring>KeyButtonGroup</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>Key Setting</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit0</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="1" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit1</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit2</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="3" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit3</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="0" column="0" > <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>keyRadio0</cstring> </property> <property stdset="1"> <name>text</name> <string>Key 1</string> </property> <property stdset="1"> <name>checked</name> <bool>true</bool> </property> </widget> <widget row="1" column="0" > <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>keyRadio1</cstring> </property> <property stdset="1"> <name>text</name> @@ -440,81 +431,61 @@ </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> </widget> </vbox> </widget> <connections> <connection> - <sender>essSpecific</sender> - <signal>toggled(bool)</signal> - <receiver>essSpecificLineEdit</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>network802</sender> - <signal>clicked()</signal> - <receiver>essSpecific</receiver> - <slot>animateClick()</slot> - </connection> - <connection> - <sender>network802</sender> - <signal>toggled(bool)</signal> - <receiver>TextLabel2</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>network802</sender> + <sender>wepEnabled</sender> <signal>toggled(bool)</signal> - <receiver>networkChannel</receiver> + <receiver>ButtonGroup43</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>wepEnabled</sender> <signal>toggled(bool)</signal> - <receiver>ButtonGroup43</receiver> + <receiver>KeyButtonGroup</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> - <sender>wepEnabled</sender> + <sender>essAny</sender> <signal>toggled(bool)</signal> - <receiver>ButtonGroup44</receiver> + <receiver>GroupBox1</receiver> <slot>setEnabled(bool)</slot> </connection> </connections> <tabstops> <tabstop>tabWidget</tabstop> - <tabstop>essNon</tabstop> - <tabstop>essSpecific</tabstop> + <tabstop>essAny</tabstop> <tabstop>essSpecificLineEdit</tabstop> - <tabstop>networkInfrastructure</tabstop> - <tabstop>network802</tabstop> + <tabstop>networkType</tabstop> <tabstop>networkChannel</tabstop> <tabstop>wepEnabled</tabstop> <tabstop>authOpen</tabstop> <tabstop>authShared</tabstop> <tabstop>keyRadio0</tabstop> <tabstop>keyLineEdit0</tabstop> <tabstop>keyRadio1</tabstop> <tabstop>keyLineEdit1</tabstop> <tabstop>keyRadio2</tabstop> <tabstop>keyLineEdit2</tabstop> <tabstop>keyRadio3</tabstop> <tabstop>keyLineEdit3</tabstop> </tabstops> </UI> diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 6a56358..ef7329e 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -1,114 +1,119 @@ #include "wlanimp.h" #include "interfacesetupimp.h" #include <qfile.h> #include <qdir.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> +#include <qlabel.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qtabwidget.h> +#include <qcombobox.h> /* system() */ #include <stdlib.h> #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" /** * Constructor, read in the wireless.opts file for parsing later. */ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); tabWidget->insertTab(interfaceSetup, "TCP/IP"); // Read in the config file. QString wlanFile = WIRELESS_OPTS; QFile file(wlanFile); if (file.open(IO_ReadOnly)){ QTextStream stream( &file ); QString line = ""; while ( !stream.eof() ) { line += stream.readLine(); line += "\n"; } file.close(); settingsFileText = QStringList::split("\n", line, true); parseSettingFile(); } else qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); + connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); + +} + +void WLANImp::typeChanged(int mod){ + networkChannel->setEnabled(mod); + channelLabel->setEnabled(mod); } /** * Change the profile for both wireless settings and network settings. */ void WLANImp::setProfile(const QString &profile){ interfaceSetup->setProfile(profile); parseSettingFile(); } /** * Parses the settings file that was read in and gets any setting from it. */ void WLANImp::parseSettingFile(){ bool foundCase = false; bool found = false; for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); if(line.contains("case")) foundCase = true; // See if we found our scheme to write or the sceme couldn't be found if((foundCase && line.contains("esac")) || (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) found = true; if(line.contains(";;")) found = false; if(found){ // write out scheme if(line.contains("ESSID=")){ QString id = line.mid(line.find("ESSID=")+6, line.length()); if(id == "any"){ - essNon->setChecked(true); - essSpecific->setChecked(false); + essAny->setChecked(false); }else{ - essSpecific->setChecked(true); + essAny->setChecked(true); essSpecificLineEdit->setText(id); - essNon->setChecked(false); } } if(line.contains("MODE=")){ QString mode = line.mid(line.find("MODE=")+5, line.length()); if(mode == "Managed"){ - network802->setChecked( false ); - networkInfrastructure->setChecked( true ); + networkType->setCurrentItem(0); } else{ - network802->setChecked( true ); - networkInfrastructure->setChecked( false ); + networkType->setCurrentItem(0); } } if(line.contains("KEY0=")) keyLineEdit0->setText(line.mid(5, line.length())); if(line.contains("KEY1=")) keyLineEdit1->setText(line.mid(5, line.length())); if(line.contains("KEY2=")) keyLineEdit2->setText(line.mid(5, line.length())); if(line.contains("KEY3=")) keyLineEdit3->setText(line.mid(5, line.length())); if(line.contains("KEY=")){ wepEnabled->setChecked(true); QString key; if(line.right(5) == (" open")){ key = line.mid(4, line.length()-5); authOpen->setChecked(true); authShared->setChecked(false); } else{ authOpen->setChecked(false); authShared->setChecked(true); key = line.mid(4, line.length()); } @@ -133,95 +138,107 @@ void WLANImp::changeAndSaveSettingFile(){ QFile file(wlanFile); if (!file.open(IO_ReadWrite)){ qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); return; } QTextStream stream( &file ); bool foundCase = false; bool found = false; bool output = true; for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); if(line.contains("case")) foundCase = true; // See if we found our scheme to write or the sceme couldn't be found if((foundCase && line.contains("esac") && !found) || (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ // write out scheme found = true; output = false; if(!line.contains("esac")) stream << line << "\n"; - - stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; - stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n'; - + if(!essAny->isChecked() == true){ + stream << "\tESSID=any\n"; + stream << "\tMODE=Managed\n"; + stream << "\tCHANNEL=6\n"; + } + else{ + stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; + stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; + stream << "\tCHANNEL=" << networkChannel->value() << "\n"; + } + stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; if(wepEnabled->isChecked()){ stream << "\tKEY=\""; if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); if(authOpen->isChecked()) stream << " open"; else stream << " restricted"; stream << "\"\n"; } - stream << "\tCHANNEL=" << networkChannel->value() << "\n"; stream << "\tRATE=auto\n"; if(line.contains("esac")) stream << line << "\n"; } if(line.contains(";;")) output = true; if(output && (*it).length() ) stream << (*it) << '\n'; } file.close(); } /** * Check to see if the current config is valid * Save wireless.opts, save interfaces */ void WLANImp::accept(){ if(wepEnabled->isChecked()){ if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) { - QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); + QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); return; } } + if(essSpecificLineEdit->text().isEmpty()){ + QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); + return; + } + // Ok settings are good here, save changeAndSaveSettingFile(); // Try to save the interfaces settings. if(!interfaceSetup->saveChanges()) return; + return; // Restart the device now that the settings have changed QString initpath; if( QDir("/etc/rc.d/init.d").exists() ) initpath = "/etc/rc.d/init.d"; else if( QDir("/etc/init.d").exists() ) initpath = "/etc/init.d"; if( initpath ) system(QString("%1/pcmcia stop").arg(initpath)); if( initpath ) system(QString("%1/pcmcia start").arg(initpath)); // Close out the dialog QDialog::accept(); } // wlanimp.cpp diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h index df599af..310836c 100644 --- a/noncore/net/networksetup/wlan/wlanimp.h +++ b/noncore/net/networksetup/wlan/wlanimp.h @@ -1,31 +1,34 @@ #ifndef WLANIMP_H #define WLANIMP_H #include "wlan.h" #include <qstringlist.h> class InterfaceSetupImp; class Interface; class Config; class WLANImp : public WLAN { Q_OBJECT public: WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); void setProfile(const QString &profile); protected: void accept(); +private slots: + void typeChanged(int); + private: void parseSettingFile(); void changeAndSaveSettingFile(); InterfaceSetupImp *interfaceSetup; QStringList settingsFileText; QString currentProfile; }; #endif diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui index 47d6db6..09593b3 100644 --- a/noncore/settings/networksettings/wlan/wlan.ui +++ b/noncore/settings/networksettings/wlan/wlan.ui @@ -1,39 +1,39 @@ <!DOCTYPE UI><UI> <class>WLAN</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>WLAN</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>237</width> - <height>286</height> + <width>239</width> + <height>277</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Wireless LAN Setting</string> </property> <property stdset="1"> <name>sizeGripEnabled</name> <bool>true</bool> </property> <property> <name>layoutMargin</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> @@ -44,192 +44,167 @@ <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>ConfigPage</cstring> </property> <attribute> <name>title</name> <string>WLAN General</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> - <class>QButtonGroup</class> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>essAny</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Sepecify Access Point</string> + </property> + </widget> + <widget> + <class>QGroupBox</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup45</cstring> + <cstring>GroupBox1</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> </property> <property stdset="1"> <name>title</name> - <string>ESS ID</string> + <string>Settings</string> </property> - <vbox> + <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> - <widget> - <class>QRadioButton</class> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>essNon</cstring> + <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> - <string>Non-Spec ESSID: "ANY"</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <string>ESS-ID</string> </property> </widget> - <widget> - <class>QRadioButton</class> + <widget row="1" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>essSpecific</cstring> + <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> - <string>Specific ESSID</string> + <string>Network Type</string> </property> </widget> - <widget> + <widget row="0" column="1" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>essSpecificLineEdit</cstring> </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> </widget> - </vbox> - </widget> - <widget> - <class>QButtonGroup</class> - <property stdset="1"> - <name>name</name> - <cstring>ButtonGroup46</cstring> - </property> - <property stdset="1"> - <name>title</name> - <string>Network Type</string> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>11</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget row="0" column="0" rowspan="1" colspan="3" > - <class>QRadioButton</class> + <widget row="1" column="1" rowspan="1" colspan="2" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Infrastructure</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Ad-Hoc</string> + </property> + </item> <property stdset="1"> <name>name</name> - <cstring>networkInfrastructure</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Infrastructure</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> + <cstring>networkType</cstring> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <cstring>channelLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Channel</string> </property> </widget> - <widget row="1" column="0" rowspan="1" colspan="2" > - <class>QRadioButton</class> - <property stdset="1"> - <name>name</name> - <cstring>network802</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Ad-Hoc</string> - </property> - </widget> <widget row="2" column="1" > <class>QSpinBox</class> <property stdset="1"> <name>name</name> <cstring>networkChannel</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>maxValue</name> - <number>11</number> + <number>15</number> </property> <property stdset="1"> <name>minValue</name> <number>1</number> </property> <property stdset="1"> <name>value</name> <number>6</number> </property> </widget> <spacer row="2" column="2" > <property> <name>name</name> - <cstring>Spacer32</cstring> + <cstring>Spacer4</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </grid> </widget> <spacer> <property> <name>name</name> <cstring>Spacer31</cstring> </property> @@ -315,94 +290,110 @@ <string>Open System</string> </property> <property stdset="1"> <name>checked</name> <bool>true</bool> </property> </widget> <widget> <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>authShared</cstring> </property> <property stdset="1"> <name>text</name> <string>Shared Key</string> </property> </widget> </hbox> </widget> <widget> <class>QButtonGroup</class> <property stdset="1"> <name>name</name> - <cstring>ButtonGroup44</cstring> + <cstring>KeyButtonGroup</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>Key Setting</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit0</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="1" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit1</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit2</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="3" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>keyLineEdit3</cstring> </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> + </property> </widget> <widget row="0" column="0" > <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>keyRadio0</cstring> </property> <property stdset="1"> <name>text</name> <string>Key 1</string> </property> <property stdset="1"> <name>checked</name> <bool>true</bool> </property> </widget> <widget row="1" column="0" > <class>QRadioButton</class> <property stdset="1"> <name>name</name> <cstring>keyRadio1</cstring> </property> <property stdset="1"> <name>text</name> @@ -440,81 +431,61 @@ </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> </widget> </vbox> </widget> <connections> <connection> - <sender>essSpecific</sender> - <signal>toggled(bool)</signal> - <receiver>essSpecificLineEdit</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>network802</sender> - <signal>clicked()</signal> - <receiver>essSpecific</receiver> - <slot>animateClick()</slot> - </connection> - <connection> - <sender>network802</sender> - <signal>toggled(bool)</signal> - <receiver>TextLabel2</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>network802</sender> + <sender>wepEnabled</sender> <signal>toggled(bool)</signal> - <receiver>networkChannel</receiver> + <receiver>ButtonGroup43</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>wepEnabled</sender> <signal>toggled(bool)</signal> - <receiver>ButtonGroup43</receiver> + <receiver>KeyButtonGroup</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> - <sender>wepEnabled</sender> + <sender>essAny</sender> <signal>toggled(bool)</signal> - <receiver>ButtonGroup44</receiver> + <receiver>GroupBox1</receiver> <slot>setEnabled(bool)</slot> </connection> </connections> <tabstops> <tabstop>tabWidget</tabstop> - <tabstop>essNon</tabstop> - <tabstop>essSpecific</tabstop> + <tabstop>essAny</tabstop> <tabstop>essSpecificLineEdit</tabstop> - <tabstop>networkInfrastructure</tabstop> - <tabstop>network802</tabstop> + <tabstop>networkType</tabstop> <tabstop>networkChannel</tabstop> <tabstop>wepEnabled</tabstop> <tabstop>authOpen</tabstop> <tabstop>authShared</tabstop> <tabstop>keyRadio0</tabstop> <tabstop>keyLineEdit0</tabstop> <tabstop>keyRadio1</tabstop> <tabstop>keyLineEdit1</tabstop> <tabstop>keyRadio2</tabstop> <tabstop>keyLineEdit2</tabstop> <tabstop>keyRadio3</tabstop> <tabstop>keyLineEdit3</tabstop> </tabstops> </UI> diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 6a56358..ef7329e 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -1,114 +1,119 @@ #include "wlanimp.h" #include "interfacesetupimp.h" #include <qfile.h> #include <qdir.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> +#include <qlabel.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qtabwidget.h> +#include <qcombobox.h> /* system() */ #include <stdlib.h> #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" /** * Constructor, read in the wireless.opts file for parsing later. */ WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); tabWidget->insertTab(interfaceSetup, "TCP/IP"); // Read in the config file. QString wlanFile = WIRELESS_OPTS; QFile file(wlanFile); if (file.open(IO_ReadOnly)){ QTextStream stream( &file ); QString line = ""; while ( !stream.eof() ) { line += stream.readLine(); line += "\n"; } file.close(); settingsFileText = QStringList::split("\n", line, true); parseSettingFile(); } else qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); + connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); + +} + +void WLANImp::typeChanged(int mod){ + networkChannel->setEnabled(mod); + channelLabel->setEnabled(mod); } /** * Change the profile for both wireless settings and network settings. */ void WLANImp::setProfile(const QString &profile){ interfaceSetup->setProfile(profile); parseSettingFile(); } /** * Parses the settings file that was read in and gets any setting from it. */ void WLANImp::parseSettingFile(){ bool foundCase = false; bool found = false; for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); if(line.contains("case")) foundCase = true; // See if we found our scheme to write or the sceme couldn't be found if((foundCase && line.contains("esac")) || (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) found = true; if(line.contains(";;")) found = false; if(found){ // write out scheme if(line.contains("ESSID=")){ QString id = line.mid(line.find("ESSID=")+6, line.length()); if(id == "any"){ - essNon->setChecked(true); - essSpecific->setChecked(false); + essAny->setChecked(false); }else{ - essSpecific->setChecked(true); + essAny->setChecked(true); essSpecificLineEdit->setText(id); - essNon->setChecked(false); } } if(line.contains("MODE=")){ QString mode = line.mid(line.find("MODE=")+5, line.length()); if(mode == "Managed"){ - network802->setChecked( false ); - networkInfrastructure->setChecked( true ); + networkType->setCurrentItem(0); } else{ - network802->setChecked( true ); - networkInfrastructure->setChecked( false ); + networkType->setCurrentItem(0); } } if(line.contains("KEY0=")) keyLineEdit0->setText(line.mid(5, line.length())); if(line.contains("KEY1=")) keyLineEdit1->setText(line.mid(5, line.length())); if(line.contains("KEY2=")) keyLineEdit2->setText(line.mid(5, line.length())); if(line.contains("KEY3=")) keyLineEdit3->setText(line.mid(5, line.length())); if(line.contains("KEY=")){ wepEnabled->setChecked(true); QString key; if(line.right(5) == (" open")){ key = line.mid(4, line.length()-5); authOpen->setChecked(true); authShared->setChecked(false); } else{ authOpen->setChecked(false); authShared->setChecked(true); key = line.mid(4, line.length()); } @@ -133,95 +138,107 @@ void WLANImp::changeAndSaveSettingFile(){ QFile file(wlanFile); if (!file.open(IO_ReadWrite)){ qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); return; } QTextStream stream( &file ); bool foundCase = false; bool found = false; bool output = true; for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); if(line.contains("case")) foundCase = true; // See if we found our scheme to write or the sceme couldn't be found if((foundCase && line.contains("esac") && !found) || (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ // write out scheme found = true; output = false; if(!line.contains("esac")) stream << line << "\n"; - - stream << "\tESSID=" << (essNon->isChecked() == true ? QString("any") : essSpecificLineEdit->text()) << '\n'; - stream << "\tMODE=" << (networkInfrastructure->isChecked() == true ? "Managed" : "ad-hoc") << '\n'; - + if(!essAny->isChecked() == true){ + stream << "\tESSID=any\n"; + stream << "\tMODE=Managed\n"; + stream << "\tCHANNEL=6\n"; + } + else{ + stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; + stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; + stream << "\tCHANNEL=" << networkChannel->value() << "\n"; + } + stream << "\tKEY0=" << keyLineEdit0->text() << "\n"; stream << "\tKEY1=" << keyLineEdit1->text() << "\n"; stream << "\tKEY2=" << keyLineEdit2->text() << "\n"; stream << "\tKEY3=" << keyLineEdit3->text() << "\n"; if(wepEnabled->isChecked()){ stream << "\tKEY=\""; if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); if(authOpen->isChecked()) stream << " open"; else stream << " restricted"; stream << "\"\n"; } - stream << "\tCHANNEL=" << networkChannel->value() << "\n"; stream << "\tRATE=auto\n"; if(line.contains("esac")) stream << line << "\n"; } if(line.contains(";;")) output = true; if(output && (*it).length() ) stream << (*it) << '\n'; } file.close(); } /** * Check to see if the current config is valid * Save wireless.opts, save interfaces */ void WLANImp::accept(){ if(wepEnabled->isChecked()){ if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ) { - QMessageBox::information(this, "", "Please enter a key for WEP.", QMessageBox::Ok); + QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); return; } } + if(essSpecificLineEdit->text().isEmpty()){ + QMessageBox::information(this, "Error", "Please enter a ESS-ID.", QMessageBox::Ok); + return; + } + // Ok settings are good here, save changeAndSaveSettingFile(); // Try to save the interfaces settings. if(!interfaceSetup->saveChanges()) return; + return; // Restart the device now that the settings have changed QString initpath; if( QDir("/etc/rc.d/init.d").exists() ) initpath = "/etc/rc.d/init.d"; else if( QDir("/etc/init.d").exists() ) initpath = "/etc/init.d"; if( initpath ) system(QString("%1/pcmcia stop").arg(initpath)); if( initpath ) system(QString("%1/pcmcia start").arg(initpath)); // Close out the dialog QDialog::accept(); } // wlanimp.cpp diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h index df599af..310836c 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.h +++ b/noncore/settings/networksettings/wlan/wlanimp.h @@ -1,31 +1,34 @@ #ifndef WLANIMP_H #define WLANIMP_H #include "wlan.h" #include <qstringlist.h> class InterfaceSetupImp; class Interface; class Config; class WLANImp : public WLAN { Q_OBJECT public: WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); void setProfile(const QString &profile); protected: void accept(); +private slots: + void typeChanged(int); + private: void parseSettingFile(); void changeAndSaveSettingFile(); InterfaceSetupImp *interfaceSetup; QStringList settingsFileText; QString currentProfile; }; #endif |