summaryrefslogtreecommitdiff
path: root/noncore/net/networksetup/wlan
authorbenmeyer <benmeyer>2002-10-25 19:34:32 (UTC)
committer benmeyer <benmeyer>2002-10-25 19:34:32 (UTC)
commitf16dd7fc272f3f8354dc696fcc881dfe74755a21 (patch) (side-by-side diff)
treeedaab125b322744d8684e6aee4d2c5955b68689b /noncore/net/networksetup/wlan
parent77347ba522a5913ff17561e6fd2c15981d42e86b (diff)
downloadopie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.zip
opie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.tar.gz
opie-f16dd7fc272f3f8354dc696fcc881dfe74755a21.tar.bz2
Moved Interfaces into a library
Diffstat (limited to 'noncore/net/networksetup/wlan') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/wlan/wextensions.cpp6
-rw-r--r--noncore/net/networksetup/wlan/wlan.pro4
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.cpp14
-rw-r--r--noncore/net/networksetup/wlan/wlanimp.h8
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp22
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.h4
6 files changed, 36 insertions, 22 deletions
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp
index e545bd1..eb6fc42 100644
--- a/noncore/net/networksetup/wlan/wextensions.cpp
+++ b/noncore/net/networksetup/wlan/wextensions.cpp
@@ -1,63 +1,63 @@
#include "wextensions.h"
#include <qfile.h>
#include <qtextstream.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <math.h>
#define PROCNETWIRELESS "/proc/net/wireless"
#define IW_LOWER 0
#define IW_UPPER 256
/**
* Constructor. Sets hasWirelessExtensions
*/
-WExtensions::WExtensions(QString interfaceName){
+WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){
interface = interfaceName;
fd = socket( AF_INET, SOCK_DGRAM, 0 );
+ if(fd == -1)
+ return;
const char* buffer[200];
memset( &iwr, 0, sizeof( iwr ) );
iwr.u.essid.pointer = (caddr_t) buffer;
iwr.u.essid.length = IW_ESSID_MAX_SIZE;
iwr.u.essid.flags = 0;
// check if it is an IEEE 802.11 standard conform
// wireless device by sending SIOCGIWESSID
// which also gives back the Extended Service Set ID
// (see IEEE 802.11 for more information)
const char* iname = interface.latin1();
strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) )
hasWirelessExtensions = true;
- else
- hasWirelessExtensions = false;
}
/**
* @return QString the station name of the access point.
*/
QString WExtensions::station(){
if(!hasWirelessExtensions)
return QString();
const char* buffer[200];
iwr.u.data.pointer = (caddr_t) buffer;
iwr.u.data.length = IW_ESSID_MAX_SIZE;
iwr.u.data.flags = 0;
if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){
iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0';
return QString(iwr.u.data.pointer);
}
return QString();
}
/**
* @return QString the essid of the host 802.11 access point.
*/
QString WExtensions::essid(){
if(!hasWirelessExtensions)
diff --git a/noncore/net/networksetup/wlan/wlan.pro b/noncore/net/networksetup/wlan/wlan.pro
index f28feb2..23fc39a 100644
--- a/noncore/net/networksetup/wlan/wlan.pro
+++ b/noncore/net/networksetup/wlan/wlan.pro
@@ -1,12 +1,12 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksetup
HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h
SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp
-INCLUDEPATH += $(OPIEDIR)/include ../
+INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -L../interfaces/ -linterfaces
INTERFACES = wlan.ui info.ui
TARGET = wlanplugin
VERSION = 1.0.0
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp
index 45952b9..7c902e0 100644
--- a/noncore/net/networksetup/wlan/wlanimp.cpp
+++ b/noncore/net/networksetup/wlan/wlanimp.cpp
@@ -1,45 +1,53 @@
#include "wlanimp.h"
/* Config class */
#include <qpe/config.h>
/* Global namespace */
#include <qpe/global.h>
/* system() */
#include <stdlib.h>
#include <qfile.h>
#include <qdir.h>
#include <qtextstream.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qradiobutton.h>
#include <qcheckbox.h>
#include <qregexp.h>
+#include <qpe/config.h>
+#include <qtabwidget.h>
+#include "interfacesetupimp.h"
-WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){
+WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){
config = new Config("wireless");
+ interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose);
+ //configure->setProfile(currentProfile);
+ tabWidget->insertTab(interfaceSetup, "TCP/IP");
+
readConfig();
+
}
WLANImp::~WLANImp( ){
delete config;
}
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 ) );
@@ -88,50 +96,52 @@ bool WLANImp::writeConfig()
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 true;
return writeWirelessOpts( );
}
/**
*/
void WLANImp::accept()
{
- if ( writeConfig() )
+ if ( writeConfig() ){
+ interfaceSetup->saveChanges();
QDialog::accept();
+ }
}
bool WLANImp::writeWirelessOpts( 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;
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h
index 59b7c59..608d681 100644
--- a/noncore/net/networksetup/wlan/wlanimp.h
+++ b/noncore/net/networksetup/wlan/wlanimp.h
@@ -1,27 +1,31 @@
#ifndef WLANIMP_H
#define WLANIMP_H
#include "wlan.h"
-#include <qpe/config.h>
+class InterfaceSetupImp;
+class Interface;
+class Config;
class WLANImp : public WLAN {
Q_OBJECT
public:
- WLANImp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 );
~WLANImp( );
protected:
void accept();
private:
void readConfig();
bool writeConfig();
bool writeWirelessOpts( QString scheme = "*" );
bool writeWlanngOpts( QString scheme = "*" );
Config* config;
+ InterfaceSetupImp *interfaceSetup;
+
};
#endif
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 9ab3b76..c8becb0 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,101 +1,101 @@
#include "wlanmodule.h"
#include "wlanimp.h"
#include "infoimp.h"
#include "wextensions.h"
+#include "interfaceinformationimp.h"
#include <qlabel.h>
#include <qprogressbar.h>
+#include <qtabwidget.h>
/**
* Constructor, find all of the possible interfaces
*/
WLANModule::WLANModule() : Module() {
}
/**
* 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(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, 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.
+ * Create, and return the WLANConfigure Module
+ * @return QWidget* pointer to this modules configure.
*/
-QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){
- WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose);
- (*tabWidget) = wlanconfig->tabWidget;
+QWidget *WLANModule::configure(Interface *i){
+ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose);
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.
+ * Create, and return the Information Module
+ * @return QWidget* pointer to this modules info.
*/
-QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){
+QWidget *WLANModule::information(Interface *i){
WExtensions we(i->getInterfaceName());
if(!we.doesHaveWirelessExtensions())
return NULL;
WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
- (*tabWidget) = info->tabWidget;
+ InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
+ info->tabWidget->insertTab(information, "TCP/IP");
return info;
}
/**
* 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(QString ){
// We can't add a 802.11 interface, either the hardware will be there
// or it wont.
return NULL;
}
diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h
index 1418ce8..a81ccff 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.h
+++ b/noncore/net/networksetup/wlan/wlanmodule.h
@@ -1,41 +1,41 @@
#ifndef WLAN_MODULE_H
#define WLAN_MODULE_H
#include "module.h"
class WLANModule : Module{
signals:
void updateInterface(Interface *i);
public:
WLANModule();
~WLANModule();
virtual void setProfile(QString newProfile);
virtual bool isOwner(Interface *);
- virtual QWidget *configure(Interface *i, QTabWidget **tabWidget);
- virtual QWidget *information(Interface *i, QTabWidget **tabWidget);
+ virtual QWidget *configure(Interface *i);
+ virtual QWidget *information(Interface *i);
virtual QList<Interface> getInterfaces();
virtual void possibleNewInterfaces(QMap<QString, QString> &){};
virtual Interface *addNewInterface(QString name);
virtual bool remove(Interface* i);
virtual QString getPixmapName(Interface* i);
private:
QList<Interface> list;
QString profile;
};
extern "C"
{
void* create_plugin() {
return new WLANModule();
}
};
#endif
// wlanmodule.h