summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/wlan
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/wlan') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/wlan/keyedit.cpp1
-rw-r--r--noncore/settings/networksettings/wlan/wlan.ui96
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp35
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp2
4 files changed, 74 insertions, 60 deletions
diff --git a/noncore/settings/networksettings/wlan/keyedit.cpp b/noncore/settings/networksettings/wlan/keyedit.cpp
index ad9ecae..13a1c3b 100644
--- a/noncore/settings/networksettings/wlan/keyedit.cpp
+++ b/noncore/settings/networksettings/wlan/keyedit.cpp
@@ -1,21 +1,22 @@
#include "keyedit.h"
#include <qlineedit.h>
KeyEdit::KeyEdit(QWidget* parent, const char* name) :
QLineEdit(parent, name)
{
+ setEchoMode(Password);
}
KeyEdit::~KeyEdit()
{
}
void KeyEdit::focusInEvent(QFocusEvent *event)
{
setEchoMode(Normal);
}
void KeyEdit::focusOutEvent(QFocusEvent *event)
{
setEchoMode(Password);
}
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui
index 7932445..7e39e23 100644
--- a/noncore/settings/networksettings/wlan/wlan.ui
+++ b/noncore/settings/networksettings/wlan/wlan.ui
@@ -1,718 +1,724 @@
<!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>251</width>
+ <width>247</width>
<height>299</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<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>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tabWidget</cstring>
</property>
<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>General</string>
</attribute>
<spacer>
<property>
<name>name</name>
<cstring>Spacer31</cstring>
</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>
<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>Auto</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>Managed</string>
- </property>
- </item>
- <item>
- <property>
- <name>text</name>
- <string>Ad-Hoc</string>
+ <string>any</string>
</property>
</item>
<property stdset="1">
<name>name</name>
- <cstring>mode</cstring>
- </property>
- <property stdset="1">
- <name>enabled</name>
- <bool>true</bool>
+ <cstring>essid</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>101</x>
- <y>11</y>
+ <y>46</y>
<width>103</width>
<height>29</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
- <hsizetype>1</hsizetype>
+ <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>
<class>QComboBox</class>
<item>
<property>
<name>text</name>
- <string>any</string>
+ <string>Infrastructure</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Auto</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Managed</string>
+ </property>
+ </item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>Ad-Hoc</string>
</property>
</item>
<property stdset="1">
<name>name</name>
- <cstring>essid</cstring>
+ <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>46</y>
+ <y>11</y>
<width>103</width>
<height>29</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
- <hsizetype>7</hsizetype>
+ <hsizetype>1</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>
<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>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>wepEnabled</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Enable Encryption</string>
</property>
</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>
</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>QRadioButton</class>
<property stdset="1">
<name>name</name>
<cstring>keyRadio0</cstring>
</property>
<property stdset="1">
<name>text</name>
<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 &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 &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 &amp;4</string>
</property>
</widget>
<widget row="0" column="1" >
<class>KeyEdit</class>
<property stdset="1">
<name>name</name>
<cstring>keyLineEdit0</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>StrongFocus</enum>
</property>
</widget>
<widget row="1" column="1" >
<class>KeyEdit</class>
<property stdset="1">
<name>name</name>
<cstring>keyLineEdit1</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>StrongFocus</enum>
</property>
</widget>
<widget row="2" column="1" >
<class>KeyEdit</class>
<property stdset="1">
<name>name</name>
<cstring>keyLineEdit2</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>StrongFocus</enum>
</property>
</widget>
<widget row="3" column="1" >
<class>KeyEdit</class>
<property stdset="1">
<name>name</name>
<cstring>keyLineEdit3</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>StrongFocus</enum>
</property>
</widget>
</grid>
</widget>
<widget row="2" column="0" >
<class>QButtonGroup</class>
<property stdset="1">
<name>name</name>
<cstring>NonEncButtonGroup</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>title</name>
<string>Non-encrypted Packets</string>
</property>
<property stdset="1">
<name>radioButtonExclusive</name>
<bool>true</bool>
</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>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>
<spacer row="3" column="0" >
<property>
<name>name</name>
<cstring>Spacer30</cstring>
</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>
</grid>
</widget>
</widget>
</vbox>
</widget>
<customwidgets>
<customwidget>
<class>KeyEdit</class>
<header location="local">keyedit.h</header>
<sizehint>
<width>-1</width>
<height>-1</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>5</hordata>
<verdata>5</verdata>
</sizepolicy>
<pixmap>image0</pixmap>
<slot access="public">setEnabled(bool)</slot>
</customwidget>
</customwidgets>
<images>
<image>
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
</image>
</images>
<connections>
<connection>
<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>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>wepEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>NonEncButtonGroup</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>wepEnabled</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
index cdafb4d..26e3aa9 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,269 +1,276 @@
#include "wlanimp2.h"
#include "keyedit.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) {
+WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") {
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() {
//FIXME: 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);
- }
+
+ for ( int i = 0; i < mode->count(); i++)
+ if ( mode->text( i ) == opt ) mode->setCurrentItem( i );
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();
+// FIXME: QDialog::accept();
}
void WLANImp::writeOpts() {
- bool error = false;
+ // eh can't really do anything about it other then return. :-D
+ if(!interfaces->isInterfaceSet()){
+ QMessageBox::warning(0,"Inface not set","should not happen!!!");
+ return;
+ }
+ bool error = false;
+
+ qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
+
+ if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
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()) {
+ } //else
+ if (! keyLineEdit1->text().isNull()) {
keyList += keyLineEdit1->text();
keyList += "[2]";
- } else if (! keyLineEdit2->text().isNull()) {
+ } //else
+ if (! keyLineEdit2->text().isNull()) {
keyList += keyLineEdit2->text();
keyList += "[3]";
- } else if (! keyLineEdit3->text().isNull()) {
+ } //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;
QDialog::accept();
}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index a4488f9..b4c3509 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,252 +1,252 @@
#include "wlanmodule.h"
-#include "wlanimp.h"
+#include "wlanimp2.h"
#include "infoimp.h"
#include "wextensions.h"
#include "interfaceinformationimp.h"
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qprogressbar.h>
#include <qspinbox.h>
#include <qtabwidget.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule()
: Module(),
wlanconfigWiget(0)
{
}
/**
* Delete any interfaces that we own.
*/
WLANModule::~WLANModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
void WLANModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString WLANModule::getPixmapName(Interface* ){
return "wlan";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool WLANModule::isOwner(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return false;
i->setHardwareName("802.11b");
list.append(i);
return true;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *WLANModule::configure(Interface *i){
WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose);
wlanconfig->setProfile(profile);
return wlanconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *WLANModule::information(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return NULL;
return getInfo( i );
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> WLANModule::getInterfaces(){
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *WLANModule::addNewInterface(const QString &){
// We can't add a 802.11 interface, either the hardware will be there
// or it wont.
return NULL;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool WLANModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
void WLANModule::receive(const QCString &param, const QByteArray &arg)
{
qDebug("WLANModule::receive "+param);
QStringList params = QStringList::split(",",param);
int count = params.count();
qDebug("WLANModule got %i params", count );
if (count < 2){
qDebug("Erorr less than 2 parameter");
qDebug("RETURNING");
return;
}
QDataStream stream(arg,IO_ReadOnly);
QString interface;
QString action;
int countMsgs = 0;
stream >> interface;
qDebug("got count? >%s<",interface.latin1());
if (interface == "count"){
qDebug("got count");
stream >> action;
qDebug("Got count num >%s<", action.latin1());
countMsgs = action.toInt();
}
QDialog *toShow;
//while (! stream.atEnd() ){
for (int i = 0; i < countMsgs; i++){
qDebug("start stream %d/%d",i,countMsgs);
if (stream.atEnd()){
qDebug("end of stream");
return;
}
stream >> interface;
qDebug("got iface");
stream >> action;
qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1());
// find interfaces
Interface *ifa=0;
for ( Interface *i=list.first(); i != 0; i=list.next() ){
if (i->getInterfaceName() == interface){
qDebug("WLANModule found interface %s",interface.latin1());
ifa = i;
}
}
if (ifa == 0){
qDebug("WLANModule Did not find %s",interface.latin1());
qDebug("skipping");
count = 0;
}
if (count == 2){
// those should call the interface directly
QWidget *info = getInfo( ifa );
info->showMaximized();
if ( action.contains("start" ) ){
ifa->start();
} else if ( action.contains("restart" ) ){
ifa->restart();
} else if ( action.contains("stop" ) ){
ifa->stop();
}else if ( action.contains("refresh" ) ){
ifa->refresh();
}
}else if (count == 3){
QString value;
if (!wlanconfigWiget){
//FIXME: what if it got closed meanwhile?
wlanconfigWiget = (WLANImp*) configure(ifa);
toShow = (QDialog*) wlanconfigWiget;
}
wlanconfigWiget->showMaximized();
stream >> value;
qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
if (value.isEmpty()){
qDebug("value is empty!!!\nreturning");
return;
}
if ( action.contains("ESSID") ){
QComboBox *combo = wlanconfigWiget->essid;
bool found = false;
for ( int i = 0; i < combo->count(); i++)
if ( combo->text( i ) == value ){
combo->setCurrentItem( i );
found = true;
}
if (!found) combo->insertItem( value, 0 );
}else if ( action.contains("Mode") ){
QComboBox *combo = wlanconfigWiget->mode;
for ( int i = 0; i < combo->count(); i++)
if ( combo->text( i ) == value ){
combo->setCurrentItem( i );
}
}else if (action.contains("Channel")){
bool ok;
qDebug("converting channel");
int chan = value.toInt( &ok );
if (ok){
qDebug("ok setting channel");
wlanconfigWiget->specifyChan->setChecked( true );
wlanconfigWiget->networkChannel->setValue( chan );
}
}else if (action.contains("MacAddr")){
wlanconfigWiget->specifyAp->setChecked( true );
wlanconfigWiget->macEdit->setText( value );
}else
qDebug("wlan plugin has no clue");
}
qDebug("next stream");
}// while stream
qDebug("end of stream");
if (toShow) toShow->exec();
qDebug("returning");
}
QWidget *WLANModule::getInfo( Interface *i)
{
qDebug("WLANModule::getInfo start");
WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
info->tabWidget->insertTab(information, "TCP/IP", 0);
info->tabWidget->setCurrentPage( 0 );
info->tabWidget->showPage( information );
if (info->tabWidget->currentPage() == information ) qDebug("infotab OK");
else qDebug("infotab NOT OK");
qDebug("current idx %d", info->tabWidget->currentPageIndex());
qDebug("WLANModule::getInfo return");
return info;
}