summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-14 23:31:22 (UTC)
committer kergoth <kergoth>2003-04-14 23:31:22 (UTC)
commitfb07cc161b4adc5bc250569599a7164af2d7caba (patch) (side-by-side diff)
tree1f391e35146e81835af5e0a395896b3fe3c0d46b
parent68c558ca78e5416145b64ca87fd01361f033ef34 (diff)
downloadopie-fb07cc161b4adc5bc250569599a7164af2d7caba.zip
opie-fb07cc161b4adc5bc250569599a7164af2d7caba.tar.gz
opie-fb07cc161b4adc5bc250569599a7164af2d7caba.tar.bz2
Add new wireless parser that uses the wireless-tools if-pre-up.d
script to handle wireless configuration, as opposed to pcmcia-cs wireless.opts. This has a number of benefits. In addition to improving clarity, this means one can now configure their wireless non-pcmcia interfaces using networksettings. The only real question is, how to handle the fact that its largely useless without the if-pre-up.d script? I'll adapt the existing wlanimp.(cpp|h) to the new .ui, and leave it as a compiletime selection for now.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/wlan.pro14
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui664
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp266
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.h37
4 files changed, 735 insertions, 246 deletions
diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro
index f193bcc..9ddc154 100644
--- a/noncore/settings/networksettings/wlan/wlan.pro
+++ b/noncore/settings/networksettings/wlan/wlan.pro
@@ -1,16 +1,26 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h
-SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp
+HEADERS = infoimp.h wlanmodule.h wextensions.h
+SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
INTERFACES = wlan.ui info.ui
TARGET = wlanplugin
VERSION = 1.0.0
+#CONFIG += wirelessopts
+wirelessopts {
+ HEADERS += wlanimp.h
+ SOURCES += wlanimp.cpp
+}
+
+! wirelessopts {
+ HEADERS += wlanimp2.h
+ SOURCES += wlanimp2.cpp
+}
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 744c559..e7c8dbb 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -2,31 +2,31 @@
<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>239</width>
- <height>277</height>
+ <width>255</width>
+ <height>299</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
- <string>Wireless LAN Setting</string>
+ <string>Wireless Configuration</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>
@@ -46,277 +46,398 @@
<bool>true</bool>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>ConfigPage</cstring>
</property>
<attribute>
<name>title</name>
<string>General</string>
</attribute>
- <vbox>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer31</cstring>
+ </property>
<property stdset="1">
- <name>margin</name>
- <number>11</number>
+ <name>orientation</name>
+ <enum>Vertical</enum>
</property>
<property stdset="1">
- <name>spacing</name>
- <number>6</number>
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
- <widget>
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>essAny</cstring>
- </property>
- <property stdset="1">
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>modeLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>11</x>
+ <y>11</y>
+ <width>84</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Mode</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>essidLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>11</x>
+ <y>46</y>
+ <width>84</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>ESS-ID</string>
+ </property>
+ </widget>
+ <widget>
+ <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>geometry</name>
+ <rect>
+ <x>146</x>
+ <y>139</y>
+ <width>58</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>maxValue</name>
+ <number>15</number>
+ </property>
+ <property stdset="1">
+ <name>minValue</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>value</name>
+ <number>1</number>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>macEdit</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>56</x>
+ <y>108</y>
+ <width>182</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>macLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>false</bool>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>11</x>
+ <y>108</y>
+ <width>39</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>MAC</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>specifyAp</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>11</x>
+ <y>81</y>
+ <width>227</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Specify &amp;Access Point</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>specifyChan</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>11</x>
+ <y>141</y>
+ <width>129</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Specify &amp;Channel</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer10</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>
+ <widget>
+ <class>QComboBox</class>
+ <item>
+ <property>
<name>text</name>
- <string>&amp;Specify Access Point</string>
+ <string>Auto</string>
</property>
- </widget>
- <widget>
- <class>QGroupBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>GroupBox1</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>false</bool>
- </property>
- <property stdset="1">
- <name>title</name>
- <string>Specific &amp;Access Point Settings</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" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>ESS-ID</string>
- </property>
- </widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel2</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Network Type</string>
- </property>
- </widget>
- <widget row="0" column="1" rowspan="1" colspan="2" >
- <class>QLineEdit</class>
- <property stdset="1">
- <name>name</name>
- <cstring>essSpecificLineEdit</cstring>
- </property>
- </widget>
- <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>networkType</cstring>
- </property>
- </widget>
- <widget row="2" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>channelLabel</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Channel</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>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>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>
+ </item>
+ <item>
<property>
- <name>name</name>
- <cstring>Spacer31</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
+ <name>text</name>
+ <string>Managed</string>
</property>
- <property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Ad-Hoc</string>
</property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>mode</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>101</x>
+ <y>11</y>
+ <width>103</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <item>
<property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <name>text</name>
+ <string>any</string>
</property>
- </spacer>
- </vbox>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>essid</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>101</x>
+ <y>46</y>
+ <width>103</width>
+ <height>29</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>editable</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>currentItem</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>sizeLimit</name>
+ <number>5</number>
+ </property>
+ <property stdset="1">
+ <name>autoCompletion</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>duplicatesEnabled</name>
+ <bool>false</bool>
+ </property>
+ </widget>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>WepPage</cstring>
</property>
<attribute>
<name>title</name>
<string>Encryption</string>
</attribute>
- <vbox>
+ <grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget>
- <class>QCheckBox</class>
- <property stdset="1">
+ <spacer row="0" column="0" >
+ <property>
<name>name</name>
- <cstring>wepEnabled</cstring>
+ <cstring>Spacer30</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>&amp;Enable WEP</string>
+ <name>orientation</name>
+ <enum>Vertical</enum>
</property>
- </widget>
- <widget>
- <class>QButtonGroup</class>
<property stdset="1">
- <name>name</name>
- <cstring>ButtonGroup43</cstring>
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
</property>
+ </spacer>
+ <widget row="0" column="0" >
+ <class>QCheckBox</class>
<property stdset="1">
- <name>enabled</name>
- <bool>false</bool>
+ <name>name</name>
+ <cstring>wepEnabled</cstring>
</property>
<property stdset="1">
- <name>title</name>
- <string>&amp;Authentication Type</string>
+ <name>text</name>
+ <string>&amp;Enable Encryption</string>
</property>
- <hbox>
- <property stdset="1">
- <name>margin</name>
- <number>11</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget>
- <class>QRadioButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>authOpen</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>&amp;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>&amp;Shared Key</string>
- </property>
- </widget>
- </hbox>
</widget>
- <widget>
+ <widget row="1" column="0" >
<class>QButtonGroup</class>
<property stdset="1">
<name>name</name>
<cstring>KeyButtonGroup</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>title</name>
<string>&amp;Key Setting</string>
@@ -373,119 +494,174 @@
<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>
+ <string>Key &amp;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>
- <string>Key 2</string>
+ <string>Key &amp;2</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>keyRadio2</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Key 3</string>
+ <string>Key &amp;3</string>
</property>
</widget>
<widget row="3" column="0" >
<class>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>keyRadio3</cstring>
</property>
<property stdset="1">
<name>text</name>
- <string>Key 4</string>
+ <string>Key &amp;4</string>
</property>
</widget>
</grid>
</widget>
- <spacer>
- <property>
+ <widget row="2" column="0" >
+ <class>QButtonGroup</class>
+ <property stdset="1">
<name>name</name>
- <cstring>Spacer30</cstring>
+ <cstring>NonEncButtonGroup</cstring>
</property>
<property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
+ <name>enabled</name>
+ <bool>false</bool>
</property>
<property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
+ <name>title</name>
+ <string>Non-encrypted Packets</string>
</property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <property stdset="1">
+ <name>radioButtonExclusive</name>
+ <bool>true</bool>
</property>
- </spacer>
- </vbox>
+ <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" >
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>acceptNonEnc</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Accept</string>
+ </property>
+ <property stdset="1">
+ <name>checked</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>buttonGroupId</name>
+ <number>0</number>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QRadioButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>rejectNonEnc</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&amp;Reject</string>
+ </property>
+ <property stdset="1">
+ <name>buttonGroupId</name>
+ <number>1</number>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
</widget>
</widget>
</vbox>
</widget>
<connections>
<connection>
- <sender>wepEnabled</sender>
+ <sender>specifyAp</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>macLabel</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>specifyAp</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>macEdit</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>specifyChan</sender>
<signal>toggled(bool)</signal>
- <receiver>ButtonGroup43</receiver>
+ <receiver>networkChannel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>wepEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>KeyButtonGroup</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
- <sender>essAny</sender>
+ <sender>wepEnabled</sender>
<signal>toggled(bool)</signal>
- <receiver>GroupBox1</receiver>
+ <receiver>NonEncButtonGroup</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<tabstops>
<tabstop>tabWidget</tabstop>
- <tabstop>essAny</tabstop>
- <tabstop>essSpecificLineEdit</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>
+ <tabstop>acceptNonEnc</tabstop>
+ <tabstop>mode</tabstop>
+ <tabstop>essid</tabstop>
+ <tabstop>specifyAp</tabstop>
+ <tabstop>macEdit</tabstop>
+ <tabstop>specifyChan</tabstop>
+ <tabstop>networkChannel</tabstop>
</tabstops>
</UI>
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
new file mode 100644
index 0000000..01c9668
--- a/dev/null
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -0,0 +1,266 @@
+#include "wlanimp2.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>
+
+#ifdef QWS
+ #include <opie/oprocess.h>
+#else
+ #define OProcess KProcess
+ #include <kprocess.h>
+#endif
+
+#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
+#define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools"
+
+/**
+ * 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("*"), interface(i) {
+ interfaces = new Interfaces;
+ interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces);
+ tabWidget->insertTab(interfaceSetup, "TCP/IP");
+
+ // Check sanity - the existance of the wireless-tools if-pre-up script
+ QFile file(QString(PREUP));
+ if (file.exists()) {
+ qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
+ }
+}
+
+WLANImp::~WLANImp() {
+ delete interfaces;
+}
+
+/**
+ * Change the profile for both wireless settings and network settings.
+ */
+void WLANImp::setProfile(const QString &profile){
+ interfaceSetup->setProfile(profile);
+ parseOpts();
+}
+
+void WLANImp::parseOpts() {
+ bool error;
+ QString opt;
+
+ if (! interfaces->isInterfaceSet())
+ return;
+
+
+ opt = interfaces->getInterfaceOption("wireless_essid", error);
+ if(opt == "any" || opt == "off" || opt.isNull()){
+ essid->setEditText("any");
+ } else {
+ essid->setEditText(opt);
+ }
+
+ opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace();
+ if (opt == "Auto") {
+ mode->setCurrentItem(0);
+ } else if (opt == "Ad-Hoc") {
+ mode->setCurrentItem(2);
+ } else {
+ // Managed/Infrastructure mode
+ mode->setCurrentItem(1);
+ }
+
+ opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace();
+ if (! opt.isNull()) {
+ specifyAp->setChecked(true);
+ macEdit->setText(opt);
+ }
+
+ opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace();
+ if (! opt.isNull()) {
+ specifyChan->setChecked(true);
+ networkChannel->setValue(opt.toInt());
+ }
+
+ opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace();
+ if (opt.isNull())
+ opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace();
+ parseKeyStr(opt);
+}
+
+void WLANImp::parseKeyStr(QString keystr) {
+ int loc = 0;
+ int index = 1;
+ QString key;
+ QStringList keys = QStringList::split(QRegExp("\\s+"), keystr);
+ int enc = -1; // encryption state
+
+ for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) {
+ if ((*it).left(3) == "off") {
+ // encryption disabled
+ enc = 0;
+ } else if ((*it).left(2) == "on") {
+ // encryption enabled
+ enc = 1;
+ } else if ((*it).left(4) == "open") {
+ // open mode, accept non encrypted packets
+ acceptNonEnc->setChecked(true);
+ } else if ((*it).left(10) == "restricted") {
+ // restricted mode, only accept encrypted packets
+ rejectNonEnc->setChecked(true);
+ } else if ((*it).left(3) == "key") {
+ // new set of options
+ } else if ((*it).left(1) == "[") {
+ index = (*it).mid(1, 1).toInt();
+ // switch current key to index
+ switch (index) {
+ case 1:
+ keyRadio0->setChecked(true);
+ break;
+ case 2:
+ keyRadio1->setChecked(true);
+ break;
+ case 3:
+ keyRadio2->setChecked(true);
+ break;
+ case 4:
+ keyRadio3->setChecked(true);
+ break;
+ }
+ } else {
+ // key
+ key = (*it);
+ }
+ if (! key.isNull()) {
+ if (enc == -1)
+ enc = 1;
+ QStringList::Iterator next = ++it;
+ if (it == keys.end()) {
+ break;
+ }
+ if ((*(next)).left(1) == "[") {
+ // set key at index
+ index = (*(next)).mid(1, 1).toInt();
+ } else {
+ index = 1;
+ }
+ switch (index) {
+ case 1:
+ keyLineEdit0->setText(key);
+ break;
+ case 2:
+ keyLineEdit1->setText(key);
+ break;
+ case 3:
+ keyLineEdit2->setText(key);
+ break;
+ case 4:
+ keyLineEdit3->setText(key);
+ break;
+ }
+ key = QString::null;
+ }
+ }
+ if (enc == 1) {
+ wepEnabled->setChecked(true);
+ } else {
+ wepEnabled->setChecked(false);
+ }
+}
+
+/**
+ * Check to see if the current config is valid
+ * Save interfaces
+ */
+void WLANImp::accept() {
+ if (wepEnabled->isChecked()) {
+ if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
+ (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
+ (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
+ (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
+ QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
+ return;
+ }
+ }
+
+ if (essid->currentText().isEmpty()) {
+ QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
+ return;
+ }
+
+ if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
+ QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
+ return;
+ }
+
+ // Try to save the interfaces settings.
+ writeOpts();
+
+ // Close out the dialog
+ QDialog::accept();
+}
+
+void WLANImp::writeOpts() {
+ bool error = false;
+
+ interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
+ interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
+
+ if (specifyAp->isChecked()) {
+ interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
+ } else {
+ interfaces->removeInterfaceOption(QString("wireless_ap"));
+ }
+
+ if (specifyChan->isChecked()) {
+ interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
+ } else {
+ interfaces->removeInterfaceOption(QString("wireless_channel"));
+ }
+
+ if (wepEnabled->isChecked()) {
+ QStringList keyList;
+
+ if (! keyLineEdit0->text().isNull()) {
+ keyList += keyLineEdit0->text();
+ keyList += "[1]";
+ } else if (! keyLineEdit1->text().isNull()) {
+ keyList += keyLineEdit1->text();
+ keyList += "[2]";
+ } else if (! keyLineEdit2->text().isNull()) {
+ keyList += keyLineEdit2->text();
+ keyList += "[3]";
+ } else if (! keyLineEdit3->text().isNull()) {
+ keyList += keyLineEdit3->text();
+ keyList += "[4]";
+ }
+ if (acceptNonEnc->isChecked()) {
+ keyList += "open";
+ } else {
+ keyList += "restricted";
+ }
+
+ keyList += "key";
+ if (keyRadio0->isChecked()) {
+ keyList += "[1]";
+ } else if (keyRadio1->isChecked()) {
+ keyList += "[2]";
+ } else if (keyRadio2->isChecked()) {
+ keyList += "[3]";
+ } else if (keyRadio3->isChecked()) {
+ keyList += "[4]";
+ }
+ interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" ")));
+ } else {
+ interfaces->removeInterfaceOption(QString("wireless_key"));
+ }
+ interfaces->removeInterfaceOption(QString("wireless_enc"));
+
+ if(!interfaceSetup->saveChanges())
+ return;
+}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h
new file mode 100644
index 0000000..992d09a
--- a/dev/null
+++ b/noncore/settings/networksettings/wlan/wlanimp2.h
@@ -0,0 +1,37 @@
+#ifndef WLANIMP_H
+#define WLANIMP_H
+
+#include "wlan.h"
+#include "interfaces.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 );
+ ~WLANImp();
+ void setProfile(const QString &profile);
+
+protected:
+ void accept();
+
+private:
+ void parseOpts();
+ void writeOpts();
+
+ void parseKeyStr(QString keystr);
+
+ InterfaceSetupImp *interfaceSetup;
+ Interfaces *interfaces;
+ Interface *interface;
+
+ QString currentProfile;
+};
+
+#endif
+