author | benmeyer <benmeyer> | 2002-10-17 18:35:56 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-17 18:35:56 (UTC) |
commit | 0af393f729c3c6fb31b6794d31daf1dba9ed6eb6 (patch) (side-by-side diff) | |
tree | 83bf6904aa174ff026170ac6380bb857a6807468 | |
parent | 7a8d68c1dff37a5a50d1dfa84513ed1f7b7e2008 (diff) | |
download | opie-0af393f729c3c6fb31b6794d31daf1dba9ed6eb6.zip opie-0af393f729c3c6fb31b6794d31daf1dba9ed6eb6.tar.gz opie-0af393f729c3c6fb31b6794d31daf1dba9ed6eb6.tar.bz2 |
Profile changes
-rw-r--r-- | noncore/net/networksetup/interface.h | 1 | ||||
-rw-r--r-- | noncore/net/networksetup/module.h | 7 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 40 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 7 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.h | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/module.h | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 40 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.h | 2 |
10 files changed, 72 insertions, 42 deletions
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h index 7943fd6..dc9c6d3 100644 --- a/noncore/net/networksetup/interface.h +++ b/noncore/net/networksetup/interface.h @@ -1,72 +1,71 @@ #ifndef INTERFACE_H #define INTERFACE_H #include <qstring.h> #include <qobject.h> class Module; class Interface : public QObject{ Q_OBJECT signals: void updateInterface(Interface *i); public: Interface(QObject * parent=0, const char * name= "unknown", bool status = false); virtual ~Interface(){}; virtual QString getInterfaceName(){ QString n(this->name()); return n; }; virtual bool getStatus(){ return status; }; virtual void setStatus(bool newStatus); virtual bool isAttached(){ return attached; }; virtual void setAttached(bool isAttached=false); virtual QString getHardwareName(){ return hardwareName; }; virtual void setHardwareName(QString name="Unknown"); virtual Module* getModuleOwner(){ return moduleOwner; }; virtual void setModuleOwner(Module *owner=NULL); // inet information. QString getMacAddress(){ return macAddress; }; QString getIp(){ return ip; }; QString getSubnetMask(){ return subnetMask; }; QString getBroadcast(){ return broadcast; }; bool isDhcp(){ return dhcp; }; QString getDhcpServerIp(){ return dhcpServerIp; }; QString getLeaseObtained(){ return leaseObtained; }; QString getLeaseExpires(){ return leaseExpires; }; public slots: bool refresh(); void start(); void stop(); void restart(); private: // Interface information bool status; bool attached; - QString interfaceName; QString hardwareName; Module *moduleOwner; // Network information QString macAddress; QString ip; QString broadcast; QString subnetMask; bool dhcp; QString dhcpServerIp; QString leaseObtained; QString leaseExpires; }; #endif // interface.h diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h index 0c81928..a30f492 100644 --- a/noncore/net/networksetup/module.h +++ b/noncore/net/networksetup/module.h @@ -1,79 +1,86 @@ #ifndef NETCONF_MODULE_H #define NETCONF_MODULE_H #include <qobject.h> #include <qlist.h> #include <qmap.h> #include "interface.h" class QWidget; class QTabWidget; class Module : QObject{ signals: void updateInterface(Interface *i); public: Module(){}; /** + * The current profile has been changed and the module should do any + * neccesary changes also. + * @param newProfile what the profile should be changed to. + */ + virtual void setProfile(QString newProfile) = 0; + + /** * 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) */ virtual QString getPixmapName(Interface* i) = 0; /** * 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. */ virtual bool isOwner(Interface *){ 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. */ virtual QWidget *configure(QTabWidget **){ return NULL; } ; /** * 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. */ virtual QWidget *information(QTabWidget **){ return NULL; }; /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ virtual QList<Interface> getInterfaces() = 0; /** * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), * modem ppp) */ virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; /** * Attempts to create a new interface from name * @return Interface* NULL if it was unable to be created. * @param name the type of interface to create */ virtual Interface *addNewInterface(QString name) = 0; /** * Attempts to remove the interface, doesn't delete i * @return bool true if successfull, false otherwise. */ virtual bool remove(Interface* i) = 0; }; #endif // module.h diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 806643d..74eef5f 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -1,235 +1,235 @@ #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> 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 ); + essNon->setChecked( true ); } else { - essSpecific->setChecked( TRUE ); + essSpecific->setChecked( true ); essSpecificLineEdit->setText( ssid ); } QString mode = config.readEntry( "Mode", "Managed" ); if( mode == "adhoc" ) { - network802->setChecked( TRUE ); + network802->setChecked( true ); } else { - networkInfrastructure->setChecked( TRUE ); + 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( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); config.readEntry( "AuthType", "opensystem" ); - config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( TRUE ) : key128->setChecked( TRUE ); + 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 ); + keyRadio0->setChecked( true ); break; case 1: - keyRadio1->setChecked( TRUE ); + keyRadio1->setChecked( true ); break; case 2: - keyRadio2->setChecked( TRUE ); + keyRadio2->setChecked( true ); break; case 3: - keyRadio3->setChecked( TRUE ); + 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; +// 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; + return false; QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; QFile tmpFile(tmp); if ( !tmpFile.open( IO_WriteOnly ) ) - return FALSE; + return false; - bool retval = TRUE; + bool retval = true; QTextStream in( &prevFile ); QTextStream out( &tmpFile ); config.setGroup("Properties"); QString line; - bool found=FALSE; - bool done=FALSE; + 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; + found = false; continue; } else { continue; } } else { if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { - found=TRUE; + 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; + 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; + 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/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index f0394b4..9d34d75 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp @@ -1,76 +1,83 @@ #include "wlanmodule.h" #include <qpe/config.h> #include "wlanimp.h" /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { // get output from iwconfig } /** + * 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){ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); 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 = new Config("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; } /** * 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 7ebe129..833d4b1 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.h +++ b/noncore/net/networksetup/wlan/wlanmodule.h @@ -1,38 +1,40 @@ #ifndef WLAN_MODULE_H #define WLAN_MODULE_H #include "module.h" class WLANModule : Module{ signals: void updateInterface(Interface *i); public: WLANModule(); + virtual void setProfile(QString newProfile); virtual bool isOwner(Interface *); virtual QWidget *configure(QTabWidget **tabWidget); virtual QWidget *information(QTabWidget **tabWidget); virtual QList<Interface> getInterfaces(); virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; 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 diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h index 7943fd6..dc9c6d3 100644 --- a/noncore/settings/networksettings/interface.h +++ b/noncore/settings/networksettings/interface.h @@ -1,72 +1,71 @@ #ifndef INTERFACE_H #define INTERFACE_H #include <qstring.h> #include <qobject.h> class Module; class Interface : public QObject{ Q_OBJECT signals: void updateInterface(Interface *i); public: Interface(QObject * parent=0, const char * name= "unknown", bool status = false); virtual ~Interface(){}; virtual QString getInterfaceName(){ QString n(this->name()); return n; }; virtual bool getStatus(){ return status; }; virtual void setStatus(bool newStatus); virtual bool isAttached(){ return attached; }; virtual void setAttached(bool isAttached=false); virtual QString getHardwareName(){ return hardwareName; }; virtual void setHardwareName(QString name="Unknown"); virtual Module* getModuleOwner(){ return moduleOwner; }; virtual void setModuleOwner(Module *owner=NULL); // inet information. QString getMacAddress(){ return macAddress; }; QString getIp(){ return ip; }; QString getSubnetMask(){ return subnetMask; }; QString getBroadcast(){ return broadcast; }; bool isDhcp(){ return dhcp; }; QString getDhcpServerIp(){ return dhcpServerIp; }; QString getLeaseObtained(){ return leaseObtained; }; QString getLeaseExpires(){ return leaseExpires; }; public slots: bool refresh(); void start(); void stop(); void restart(); private: // Interface information bool status; bool attached; - QString interfaceName; QString hardwareName; Module *moduleOwner; // Network information QString macAddress; QString ip; QString broadcast; QString subnetMask; bool dhcp; QString dhcpServerIp; QString leaseObtained; QString leaseExpires; }; #endif // interface.h diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h index 0c81928..a30f492 100644 --- a/noncore/settings/networksettings/module.h +++ b/noncore/settings/networksettings/module.h @@ -1,79 +1,86 @@ #ifndef NETCONF_MODULE_H #define NETCONF_MODULE_H #include <qobject.h> #include <qlist.h> #include <qmap.h> #include "interface.h" class QWidget; class QTabWidget; class Module : QObject{ signals: void updateInterface(Interface *i); public: Module(){}; /** + * The current profile has been changed and the module should do any + * neccesary changes also. + * @param newProfile what the profile should be changed to. + */ + virtual void setProfile(QString newProfile) = 0; + + /** * 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) */ virtual QString getPixmapName(Interface* i) = 0; /** * 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. */ virtual bool isOwner(Interface *){ 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. */ virtual QWidget *configure(QTabWidget **){ return NULL; } ; /** * 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. */ virtual QWidget *information(QTabWidget **){ return NULL; }; /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ virtual QList<Interface> getInterfaces() = 0; /** * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), * modem ppp) */ virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; /** * Attempts to create a new interface from name * @return Interface* NULL if it was unable to be created. * @param name the type of interface to create */ virtual Interface *addNewInterface(QString name) = 0; /** * Attempts to remove the interface, doesn't delete i * @return bool true if successfull, false otherwise. */ virtual bool remove(Interface* i) = 0; }; #endif // module.h diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 806643d..74eef5f 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -1,235 +1,235 @@ #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> 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 ); + essNon->setChecked( true ); } else { - essSpecific->setChecked( TRUE ); + essSpecific->setChecked( true ); essSpecificLineEdit->setText( ssid ); } QString mode = config.readEntry( "Mode", "Managed" ); if( mode == "adhoc" ) { - network802->setChecked( TRUE ); + network802->setChecked( true ); } else { - networkInfrastructure->setChecked( TRUE ); + 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( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); config.readEntry( "AuthType", "opensystem" ); - config.readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( TRUE ) : key128->setChecked( TRUE ); + 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 ); + keyRadio0->setChecked( true ); break; case 1: - keyRadio1->setChecked( TRUE ); + keyRadio1->setChecked( true ); break; case 2: - keyRadio2->setChecked( TRUE ); + keyRadio2->setChecked( true ); break; case 3: - keyRadio3->setChecked( TRUE ); + 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; +// 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; + return false; QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; QFile tmpFile(tmp); if ( !tmpFile.open( IO_WriteOnly ) ) - return FALSE; + return false; - bool retval = TRUE; + bool retval = true; QTextStream in( &prevFile ); QTextStream out( &tmpFile ); config.setGroup("Properties"); QString line; - bool found=FALSE; - bool done=FALSE; + 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; + found = false; continue; } else { continue; } } else { if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { - found=TRUE; + 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; + 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; + 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/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index f0394b4..9d34d75 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -1,76 +1,83 @@ #include "wlanmodule.h" #include <qpe/config.h> #include "wlanimp.h" /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { // get output from iwconfig } /** + * 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){ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); 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 = new Config("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; } /** * 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/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h index 7ebe129..833d4b1 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.h +++ b/noncore/settings/networksettings/wlan/wlanmodule.h @@ -1,38 +1,40 @@ #ifndef WLAN_MODULE_H #define WLAN_MODULE_H #include "module.h" class WLANModule : Module{ signals: void updateInterface(Interface *i); public: WLANModule(); + virtual void setProfile(QString newProfile); virtual bool isOwner(Interface *); virtual QWidget *configure(QTabWidget **tabWidget); virtual QWidget *information(QTabWidget **tabWidget); virtual QList<Interface> getInterfaces(); virtual void possibleNewInterfaces(QMap<QString, QString> &list){}; 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 |