From 7019c0b5e0fcdd02fe6832673b7e34c8804b9c2d Mon Sep 17 00:00:00 2001 From: benmeyer Date: Tue, 01 Oct 2002 21:22:58 +0000 Subject: initial working wlan module --- (limited to 'noncore') diff --git a/noncore/net/networksetup/wlan/wlan.ui b/noncore/net/networksetup/wlan/wlan.ui new file mode 100644 index 0000000..dcacbe8 --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlan.ui @@ -0,0 +1,572 @@ + +WLAN + + QDialog + + name + WLAN + + + geometry + + 0 + 0 + 254 + 286 + + + + caption + Wireless LAN Setting + + + sizeGripEnabled + true + + + layoutMargin + + + + margin + 0 + + + spacing + 6 + + + QTabWidget + + name + tabWidget + + + enabled + true + + + QWidget + + name + ConfigPage + + + title + Config + + + + margin + 11 + + + spacing + 6 + + + QButtonGroup + + name + ButtonGroup45 + + + title + ESS ID + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + essNon + + + text + Non-Spec ESSID: "ANY" + + + checked + true + + + + QRadioButton + + name + essSpecific + + + text + Specific ESSID + + + + QLineEdit + + name + essSpecificLineEdit + + + enabled + false + + + + + + QButtonGroup + + name + ButtonGroup46 + + + title + Network Type + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + networkInfrastructure + + + text + Infrastructure + + + checked + true + + + + QLabel + + name + TextLabel2 + + + enabled + false + + + text + Channel + + + + QRadioButton + + name + network802 + + + text + 802.11 Ad-Hoc + + + + QSpinBox + + name + networkChannel + + + enabled + false + + + maxValue + 11 + + + minValue + 1 + + + + + name + Spacer32 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer31 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + WepPage + + + title + Wep + + + + margin + 11 + + + spacing + 6 + + + QButtonGroup + + name + ButtonGroup44 + + + enabled + false + + + title + Key Setting + + + + margin + 11 + + + spacing + 6 + + + QLineEdit + + name + keyLineEdit0 + + + + QLineEdit + + name + keyLineEdit1 + + + + QLineEdit + + name + keyLineEdit2 + + + + QLineEdit + + name + keyLineEdit3 + + + + QRadioButton + + name + keyRadio0 + + + text + Key 1 + + + checked + true + + + + QRadioButton + + name + keyRadio1 + + + text + Key 2 + + + + QRadioButton + + name + keyRadio2 + + + text + Key 3 + + + + QRadioButton + + name + keyRadio3 + + + text + Key 4 + + + + + + QButtonGroup + + name + ButtonGroup42 + + + enabled + false + + + title + Key Length + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + key40 + + + text + 40 Bits + + + checked + true + + + + QRadioButton + + name + key128 + + + text + 128 Bits + + + + + + QButtonGroup + + name + ButtonGroup43 + + + enabled + false + + + title + Authentication Type + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + authOpen + + + text + Open System + + + checked + true + + + + QRadioButton + + name + authShared + + + text + Shared Key + + + + + + + name + Spacer30 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + wepEnabled + + + text + Enable Wep + + + + + + + + + + essSpecific + toggled(bool) + essSpecificLineEdit + setEnabled(bool) + + + network802 + clicked() + essSpecific + animateClick() + + + network802 + toggled(bool) + TextLabel2 + setEnabled(bool) + + + network802 + toggled(bool) + networkChannel + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup42 + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup43 + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup44 + setEnabled(bool) + + + + tabWidget + essNon + essSpecificLineEdit + networkInfrastructure + networkChannel + key40 + key128 + authOpen + authShared + keyRadio0 + keyLineEdit0 + keyRadio1 + keyLineEdit1 + keyRadio2 + keyLineEdit2 + keyRadio3 + keyLineEdit3 + + diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp new file mode 100644 index 0000000..60ffeeb --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -0,0 +1,235 @@ +#include "wlanimp.h" + +/* Config class */ +#include +/* Global namespace */ +#include +/* system() */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +WLANImp::WLANImp( Config &cfg, QWidget* parent, const char* name):WLAN(parent, name),config(cfg){ + readConfig(); +} + +void WLANImp::readConfig() +{ + qWarning( "WLANImp::readConfig() called." ); + config.setGroup( "Properties" ); + QString ssid = config.readEntry( "SSID", "any" ); + if( ssid == "any" || ssid == "ANY" ){ + essNon->setChecked( TRUE ); + } else { + essSpecific->setChecked( TRUE ); + essSpecificLineEdit->setText( ssid ); + } + QString mode = config.readEntry( "Mode", "Managed" ); + if( mode == "adhoc" ) { + network802->setChecked( TRUE ); + } else { + networkInfrastructure->setChecked( TRUE ); + } + networkChannel->setValue( config.readNumEntry( "CHANNEL", 1 ) ); +// config.readEntry( "RATE", "auto" ); + config.readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( TRUE ) : wepEnabled->setChecked( FALSE ); + config.readEntry( "AuthType", "opensystem" ); + config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( TRUE ) : key128->setChecked( TRUE ); + int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); + switch( defaultkey ){ + case 0: + keyRadio0->setChecked( TRUE ); + break; + case 1: + keyRadio1->setChecked( TRUE ); + break; + case 2: + keyRadio2->setChecked( TRUE ); + break; + case 3: + keyRadio3->setChecked( TRUE ); + break; + } + keyLineEdit0->setText(config.readEntry( "dot11WEPDefaultKey0" )); + keyLineEdit1->setText(config.readEntry( "dot11WEPDefaultKey1" )); + keyLineEdit2->setText(config.readEntry( "dot11WEPDefaultKey2" )); + keyLineEdit3->setText(config.readEntry( "dot11WEPDefaultKey3" )); + return; +} + +bool WLANImp::writeConfig() +{ + qWarning( "WLANImp::writeConfig() called." ); + config.setGroup( "Properties" ); + if( essNon->isChecked() ) { + config.writeEntry( "SSID", "any" ); + } else { + config.writeEntry( "SSID", essSpecificLineEdit->text() ); + } + if( networkInfrastructure->isChecked() ){ + config.writeEntry( "Mode", "Managed" ); + } else if( network802->isChecked() ){ + config.writeEntry( "Mode", "adhoc" ); + } + config.writeEntry( "CHANNEL", networkChannel->value() ); +// config.readEntry( "RATE", "auto" ); + wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); + authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); + key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); + if( keyRadio0->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 0 ); + } else if( keyRadio1->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 1 ); + } else if( keyRadio2->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 2 ); + } else if( keyRadio3->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 3 ); + } + config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); + config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); + config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); + config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); + return writeWirelessOpts( config ); +// return TRUE; +} + +/** + */ +void WLANImp::accept() +{ + if ( writeConfig() ) + QDialog::accept(); +} + +void WLANImp::done ( int r ) +{ + QDialog::done ( r ); + close ( ); +} + +bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) +{ + qWarning( "WLANImp::writeWirelessOpts entered." ); + QString prev = "/etc/pcmcia/wireless.opts"; + QFile prevFile(prev); + if ( !prevFile.open( IO_ReadOnly ) ) + return FALSE; + + QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; + QFile tmpFile(tmp); + if ( !tmpFile.open( IO_WriteOnly ) ) + return FALSE; + + bool retval = TRUE; + + QTextStream in( &prevFile ); + QTextStream out( &tmpFile ); + + config.setGroup("Properties"); + + QString line; + bool found=FALSE; + bool done=FALSE; + while ( !in.atEnd() ) { + QString line = in.readLine(); + QString wline = line.simplifyWhiteSpace(); + if ( !done ) { + if ( found ) { + // skip existing entry for this scheme, and write our own. + if ( wline == ";;" ) { + found = FALSE; + continue; + } else { + continue; + } + } else { + if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { + found=TRUE; + continue; // skip this line + } else if ( wline == "esac" || wline == "*,*,*,*)" ) { + // end - add new entry + // Not all fields have a GUI, but all are supported + // in the letwork configuration files. + static const char* txtfields[] = { + 0 + }; + QString readmode = config.readEntry( "Mode", "Managed" ); + QString mode; + if( readmode == "Managed" ){ + mode = readmode; + } else if( readmode == "adhoc" ){ + mode = "Ad-Hoc"; + } + QString key; + if( wepEnabled->isChecked() ){ + int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); + switch( defaultkey ){ + case 0: + key += keyLineEdit0->text(); + break; + case 1: + key += keyLineEdit1->text(); + break; + case 2: + key += keyLineEdit2->text(); + break; + case 3: + key += keyLineEdit3->text(); + break; + } + if( config.readEntry( "AuthType", "opensystem" ) == "opensystem") + key += " open"; + } + out << scheme << ",*,*,*)" << "\n" + << " ESSID=" << Global::shellQuote( config.readEntry( "SSID", "any" ) ) << "\n" + << " MODE=" << mode << "\n" + << " KEY=" << Global::shellQuote( key ) << "\n" + << " RATE=" << "auto" << "\n" + ; + if( mode != "Managed" ) + out << " CHANNEL=" << config.readNumEntry( "CHANNEL", 1 ) << "\n"; + const char** f = txtfields; + while (*f) { + out << " " << *f << "=" << config.readEntry(*f,"") << "\n"; + ++f; + } + out << " ;;\n"; + done = TRUE; + } + } + } + out << line << "\n"; + } + + prevFile.close(); + tmpFile.close(); + QString initpath; + //system("cardctl suspend"); + 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( system( "mv " + tmp + " " + prev ) ) + retval = FALSE; +//#ifdef USE_SCHEMES +// if ( retval ) +// SchemeChanger::changeScheme(scheme); +//#endif + + //system("cardctl resume"); + if( initpath ) + system(QString("%1/pcmcia start").arg(initpath)); + + return retval; +} diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h new file mode 100644 index 0000000..8e355ce --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlanimp.h @@ -0,0 +1,27 @@ +#ifndef WLANIMP_H +#define WLANIMP_H + +#include "wlan.h" + +class Config; + +class WLANImp : public WLAN { + Q_OBJECT + +public: + WLANImp( Config& cfg, QWidget* parent = 0, const char* name = 0); + +protected: + void accept(); + void done ( int r ); + +private: + void readConfig(); + bool writeConfig(); + bool writeWirelessOpts( Config &cfg, QString scheme = "*" ); + bool writeWlanngOpts( Config &cfg, QString scheme = "*" ); + Config& config; +}; + +#endif + diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp new file mode 100644 index 0000000..632f7e4 --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp @@ -0,0 +1,85 @@ +#include "wlanmodule.h" +#include +#include "wlanimp.h" + +/** + * Constructor, find all of the possible interfaces + */ +WLANModule::WLANModule() : Module() { + // get output from iwconfig +} + +/** + * 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. + * @return bool true if i is owned by this module, false otherwise. + */ +bool WLANModule::isOwner(Interface *i){ + if(i->getInterfaceName() == "eth0") + return true; + return false; +} + +/** + * Create, set tabWiget and return the WLANConfigure Module + * @param tabWidget a pointer to the tab widget that this configure has. + * @return QWidget* pointer to the tab widget in this modules configure. + */ +QWidget *WLANModule::configure(QTabWidget **tabWidget){ + Config cfg("wireless"); + WLANImp *wlanconfig = new WLANImp(cfg); + (*tabWidget) = wlanconfig->tabWidget; + return wlanconfig; +} + +/** + * Create, set tabWiget and return the Information Module + * @param tabWidget a pointer to the tab widget that this information has. + * @return QWidget* pointer to the tab widget in this modules info. + */ +QWidget *WLANModule::information(QTabWidget **tabWidget){ + return NULL; +} + +/** + * + */ +QList WLANModule::getInterfaces(){ + return list +} + +/** + * Return a list of possible new interfaces + */ +QMap WLANModule::possibleNewInterfaces(){ + //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(QString name){ + return NULL; +} + +/** + * Attempts to remove the interface, doesn't delete i + * @return bool true if successfull, false otherwise. + */ +bool WLANModule::remove(Interface* i){ + return false; +} + +// wlanmodule.cpp + diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h new file mode 100644 index 0000000..1fbf6a9 --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlanmodule.h @@ -0,0 +1,38 @@ +#ifndef WLAN_MODULE_H +#define WLAN_MODULE_H + +#include "module.h" + +class WLANModule : Module{ + +signals: + void updateInterface(Interface *i); + +public: + WLANModule(); + + virtual bool isOwner(Interface *); + virtual QWidget *configure(QTabWidget **tabWidget); + virtual QWidget *information(QTabWidget **tabWidget); + virtual QList getInterfaces(); + virtual QMap possibleNewInterfaces(); + virtual Interface *addNewInterface(QString name); + virtual bool remove(Interface* i); + virtual QString getPixmapName(Interface* i); + +private: + QList list; + +}; + +extern "C" +{ + void* create_plugin() { + return new WLANModule(); + } +}; + +#endif + +// wlanmodule.h + diff --git a/noncore/net/networksetup/wlan/wlansetup.pro b/noncore/net/networksetup/wlan/wlansetup.pro new file mode 100644 index 0000000..7102adb --- a/dev/null +++ b/noncore/net/networksetup/wlan/wlansetup.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +#CONFIG += qt warn_on debug +#DESTDIR = $(OPIEDIR)/bin +HEADERS = wlanimp.h wlanmodule.h +SOURCES = wlanimp.cpp wlanmodule.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe +INTERFACES = wlan.ui +TARGET = wlanplugin +VERSION = 1.0.0 diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui new file mode 100644 index 0000000..dcacbe8 --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlan.ui @@ -0,0 +1,572 @@ + +WLAN + + QDialog + + name + WLAN + + + geometry + + 0 + 0 + 254 + 286 + + + + caption + Wireless LAN Setting + + + sizeGripEnabled + true + + + layoutMargin + + + + margin + 0 + + + spacing + 6 + + + QTabWidget + + name + tabWidget + + + enabled + true + + + QWidget + + name + ConfigPage + + + title + Config + + + + margin + 11 + + + spacing + 6 + + + QButtonGroup + + name + ButtonGroup45 + + + title + ESS ID + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + essNon + + + text + Non-Spec ESSID: "ANY" + + + checked + true + + + + QRadioButton + + name + essSpecific + + + text + Specific ESSID + + + + QLineEdit + + name + essSpecificLineEdit + + + enabled + false + + + + + + QButtonGroup + + name + ButtonGroup46 + + + title + Network Type + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + networkInfrastructure + + + text + Infrastructure + + + checked + true + + + + QLabel + + name + TextLabel2 + + + enabled + false + + + text + Channel + + + + QRadioButton + + name + network802 + + + text + 802.11 Ad-Hoc + + + + QSpinBox + + name + networkChannel + + + enabled + false + + + maxValue + 11 + + + minValue + 1 + + + + + name + Spacer32 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer31 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QWidget + + name + WepPage + + + title + Wep + + + + margin + 11 + + + spacing + 6 + + + QButtonGroup + + name + ButtonGroup44 + + + enabled + false + + + title + Key Setting + + + + margin + 11 + + + spacing + 6 + + + QLineEdit + + name + keyLineEdit0 + + + + QLineEdit + + name + keyLineEdit1 + + + + QLineEdit + + name + keyLineEdit2 + + + + QLineEdit + + name + keyLineEdit3 + + + + QRadioButton + + name + keyRadio0 + + + text + Key 1 + + + checked + true + + + + QRadioButton + + name + keyRadio1 + + + text + Key 2 + + + + QRadioButton + + name + keyRadio2 + + + text + Key 3 + + + + QRadioButton + + name + keyRadio3 + + + text + Key 4 + + + + + + QButtonGroup + + name + ButtonGroup42 + + + enabled + false + + + title + Key Length + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + key40 + + + text + 40 Bits + + + checked + true + + + + QRadioButton + + name + key128 + + + text + 128 Bits + + + + + + QButtonGroup + + name + ButtonGroup43 + + + enabled + false + + + title + Authentication Type + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + authOpen + + + text + Open System + + + checked + true + + + + QRadioButton + + name + authShared + + + text + Shared Key + + + + + + + name + Spacer30 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + wepEnabled + + + text + Enable Wep + + + + + + + + + + essSpecific + toggled(bool) + essSpecificLineEdit + setEnabled(bool) + + + network802 + clicked() + essSpecific + animateClick() + + + network802 + toggled(bool) + TextLabel2 + setEnabled(bool) + + + network802 + toggled(bool) + networkChannel + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup42 + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup43 + setEnabled(bool) + + + wepEnabled + toggled(bool) + ButtonGroup44 + setEnabled(bool) + + + + tabWidget + essNon + essSpecificLineEdit + networkInfrastructure + networkChannel + key40 + key128 + authOpen + authShared + keyRadio0 + keyLineEdit0 + keyRadio1 + keyLineEdit1 + keyRadio2 + keyLineEdit2 + keyRadio3 + keyLineEdit3 + + diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp new file mode 100644 index 0000000..60ffeeb --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -0,0 +1,235 @@ +#include "wlanimp.h" + +/* Config class */ +#include +/* Global namespace */ +#include +/* system() */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +WLANImp::WLANImp( Config &cfg, QWidget* parent, const char* name):WLAN(parent, name),config(cfg){ + readConfig(); +} + +void WLANImp::readConfig() +{ + qWarning( "WLANImp::readConfig() called." ); + config.setGroup( "Properties" ); + QString ssid = config.readEntry( "SSID", "any" ); + if( ssid == "any" || ssid == "ANY" ){ + essNon->setChecked( TRUE ); + } else { + essSpecific->setChecked( TRUE ); + essSpecificLineEdit->setText( ssid ); + } + QString mode = config.readEntry( "Mode", "Managed" ); + if( mode == "adhoc" ) { + network802->setChecked( TRUE ); + } else { + networkInfrastructure->setChecked( TRUE ); + } + networkChannel->setValue( config.readNumEntry( "CHANNEL", 1 ) ); +// config.readEntry( "RATE", "auto" ); + config.readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( TRUE ) : wepEnabled->setChecked( FALSE ); + config.readEntry( "AuthType", "opensystem" ); + config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( TRUE ) : key128->setChecked( TRUE ); + int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); + switch( defaultkey ){ + case 0: + keyRadio0->setChecked( TRUE ); + break; + case 1: + keyRadio1->setChecked( TRUE ); + break; + case 2: + keyRadio2->setChecked( TRUE ); + break; + case 3: + keyRadio3->setChecked( TRUE ); + break; + } + keyLineEdit0->setText(config.readEntry( "dot11WEPDefaultKey0" )); + keyLineEdit1->setText(config.readEntry( "dot11WEPDefaultKey1" )); + keyLineEdit2->setText(config.readEntry( "dot11WEPDefaultKey2" )); + keyLineEdit3->setText(config.readEntry( "dot11WEPDefaultKey3" )); + return; +} + +bool WLANImp::writeConfig() +{ + qWarning( "WLANImp::writeConfig() called." ); + config.setGroup( "Properties" ); + if( essNon->isChecked() ) { + config.writeEntry( "SSID", "any" ); + } else { + config.writeEntry( "SSID", essSpecificLineEdit->text() ); + } + if( networkInfrastructure->isChecked() ){ + config.writeEntry( "Mode", "Managed" ); + } else if( network802->isChecked() ){ + config.writeEntry( "Mode", "adhoc" ); + } + config.writeEntry( "CHANNEL", networkChannel->value() ); +// config.readEntry( "RATE", "auto" ); + wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); + authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); + key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); + if( keyRadio0->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 0 ); + } else if( keyRadio1->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 1 ); + } else if( keyRadio2->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 2 ); + } else if( keyRadio3->isChecked() ){ + config.writeEntry( "dot11WEPDefaultKeyID", 3 ); + } + config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); + config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); + config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); + config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); + return writeWirelessOpts( config ); +// return TRUE; +} + +/** + */ +void WLANImp::accept() +{ + if ( writeConfig() ) + QDialog::accept(); +} + +void WLANImp::done ( int r ) +{ + QDialog::done ( r ); + close ( ); +} + +bool WLANImp::writeWirelessOpts( Config &config, QString scheme ) +{ + qWarning( "WLANImp::writeWirelessOpts entered." ); + QString prev = "/etc/pcmcia/wireless.opts"; + QFile prevFile(prev); + if ( !prevFile.open( IO_ReadOnly ) ) + return FALSE; + + QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; + QFile tmpFile(tmp); + if ( !tmpFile.open( IO_WriteOnly ) ) + return FALSE; + + bool retval = TRUE; + + QTextStream in( &prevFile ); + QTextStream out( &tmpFile ); + + config.setGroup("Properties"); + + QString line; + bool found=FALSE; + bool done=FALSE; + while ( !in.atEnd() ) { + QString line = in.readLine(); + QString wline = line.simplifyWhiteSpace(); + if ( !done ) { + if ( found ) { + // skip existing entry for this scheme, and write our own. + if ( wline == ";;" ) { + found = FALSE; + continue; + } else { + continue; + } + } else { + if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { + found=TRUE; + continue; // skip this line + } else if ( wline == "esac" || wline == "*,*,*,*)" ) { + // end - add new entry + // Not all fields have a GUI, but all are supported + // in the letwork configuration files. + static const char* txtfields[] = { + 0 + }; + QString readmode = config.readEntry( "Mode", "Managed" ); + QString mode; + if( readmode == "Managed" ){ + mode = readmode; + } else if( readmode == "adhoc" ){ + mode = "Ad-Hoc"; + } + QString key; + if( wepEnabled->isChecked() ){ + int defaultkey = config.readNumEntry( "dot11WEPDefaultKeyID", 0 ); + switch( defaultkey ){ + case 0: + key += keyLineEdit0->text(); + break; + case 1: + key += keyLineEdit1->text(); + break; + case 2: + key += keyLineEdit2->text(); + break; + case 3: + key += keyLineEdit3->text(); + break; + } + if( config.readEntry( "AuthType", "opensystem" ) == "opensystem") + key += " open"; + } + out << scheme << ",*,*,*)" << "\n" + << " ESSID=" << Global::shellQuote( config.readEntry( "SSID", "any" ) ) << "\n" + << " MODE=" << mode << "\n" + << " KEY=" << Global::shellQuote( key ) << "\n" + << " RATE=" << "auto" << "\n" + ; + if( mode != "Managed" ) + out << " CHANNEL=" << config.readNumEntry( "CHANNEL", 1 ) << "\n"; + const char** f = txtfields; + while (*f) { + out << " " << *f << "=" << config.readEntry(*f,"") << "\n"; + ++f; + } + out << " ;;\n"; + done = TRUE; + } + } + } + out << line << "\n"; + } + + prevFile.close(); + tmpFile.close(); + QString initpath; + //system("cardctl suspend"); + 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( system( "mv " + tmp + " " + prev ) ) + retval = FALSE; +//#ifdef USE_SCHEMES +// if ( retval ) +// SchemeChanger::changeScheme(scheme); +//#endif + + //system("cardctl resume"); + if( initpath ) + system(QString("%1/pcmcia start").arg(initpath)); + + return retval; +} diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h new file mode 100644 index 0000000..8e355ce --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlanimp.h @@ -0,0 +1,27 @@ +#ifndef WLANIMP_H +#define WLANIMP_H + +#include "wlan.h" + +class Config; + +class WLANImp : public WLAN { + Q_OBJECT + +public: + WLANImp( Config& cfg, QWidget* parent = 0, const char* name = 0); + +protected: + void accept(); + void done ( int r ); + +private: + void readConfig(); + bool writeConfig(); + bool writeWirelessOpts( Config &cfg, QString scheme = "*" ); + bool writeWlanngOpts( Config &cfg, QString scheme = "*" ); + Config& config; +}; + +#endif + diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp new file mode 100644 index 0000000..632f7e4 --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -0,0 +1,85 @@ +#include "wlanmodule.h" +#include +#include "wlanimp.h" + +/** + * Constructor, find all of the possible interfaces + */ +WLANModule::WLANModule() : Module() { + // get output from iwconfig +} + +/** + * 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. + * @return bool true if i is owned by this module, false otherwise. + */ +bool WLANModule::isOwner(Interface *i){ + if(i->getInterfaceName() == "eth0") + return true; + return false; +} + +/** + * Create, set tabWiget and return the WLANConfigure Module + * @param tabWidget a pointer to the tab widget that this configure has. + * @return QWidget* pointer to the tab widget in this modules configure. + */ +QWidget *WLANModule::configure(QTabWidget **tabWidget){ + Config cfg("wireless"); + WLANImp *wlanconfig = new WLANImp(cfg); + (*tabWidget) = wlanconfig->tabWidget; + return wlanconfig; +} + +/** + * Create, set tabWiget and return the Information Module + * @param tabWidget a pointer to the tab widget that this information has. + * @return QWidget* pointer to the tab widget in this modules info. + */ +QWidget *WLANModule::information(QTabWidget **tabWidget){ + return NULL; +} + +/** + * + */ +QList WLANModule::getInterfaces(){ + return list +} + +/** + * Return a list of possible new interfaces + */ +QMap WLANModule::possibleNewInterfaces(){ + //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(QString name){ + return NULL; +} + +/** + * Attempts to remove the interface, doesn't delete i + * @return bool true if successfull, false otherwise. + */ +bool WLANModule::remove(Interface* i){ + return false; +} + +// wlanmodule.cpp + diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h new file mode 100644 index 0000000..1fbf6a9 --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlanmodule.h @@ -0,0 +1,38 @@ +#ifndef WLAN_MODULE_H +#define WLAN_MODULE_H + +#include "module.h" + +class WLANModule : Module{ + +signals: + void updateInterface(Interface *i); + +public: + WLANModule(); + + virtual bool isOwner(Interface *); + virtual QWidget *configure(QTabWidget **tabWidget); + virtual QWidget *information(QTabWidget **tabWidget); + virtual QList getInterfaces(); + virtual QMap possibleNewInterfaces(); + virtual Interface *addNewInterface(QString name); + virtual bool remove(Interface* i); + virtual QString getPixmapName(Interface* i); + +private: + QList list; + +}; + +extern "C" +{ + void* create_plugin() { + return new WLANModule(); + } +}; + +#endif + +// wlanmodule.h + diff --git a/noncore/settings/networksettings/wlan/wlansetup.pro b/noncore/settings/networksettings/wlan/wlansetup.pro new file mode 100644 index 0000000..7102adb --- a/dev/null +++ b/noncore/settings/networksettings/wlan/wlansetup.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +#CONFIG += qt warn_on debug +#DESTDIR = $(OPIEDIR)/bin +HEADERS = wlanimp.h wlanmodule.h +SOURCES = wlanimp.cpp wlanmodule.cpp +INCLUDEPATH += $(OPIEDIR)/include ../ +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe +INTERFACES = wlan.ui +TARGET = wlanplugin +VERSION = 1.0.0 -- cgit v0.9.0.2