author | benmeyer <benmeyer> | 2002-10-22 21:04:58 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-22 21:04:58 (UTC) |
commit | c306ba7e1c73ec200b1621d224fc77f45e798e13 (patch) (side-by-side diff) | |
tree | 1eb110c64b99c2e6ea2f8ab44c053f1e65f320f3 /noncore | |
parent | 1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f (diff) | |
download | opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.zip opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.gz opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.bz2 |
Fix segfault
-rw-r--r-- | noncore/net/networksetup/TODO | 6 | ||||
-rw-r--r-- | noncore/net/networksetup/interface.cpp | 4 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/networksettings/TODO | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 20 |
12 files changed, 36 insertions, 36 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index 7a71142..d61c510 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO @@ -1,11 +1,9 @@ WLAN needs to be re-written to not use Config --remove WLAN Config item --sub class out the wlan info --check if an interface supports wireless extensions before config. +WHERE Is DHCP info stored??? PPP module needs to be written Write a class that parses /proc and not ifconfig -Possible other modules: ipsec, bluetooth +Possible other modules: ipsec, bluetooth, ipchains diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index a84b91f..929b3a1 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp @@ -1,33 +1,33 @@ #include "interface.h" #include <qdatetime.h> #include <qfile.h> #include <qdir.h> #include <qfileinfo.h> #include <qtextstream.h> #define IFCONFIG "/sbin/ifconfig" -#define HDCP_INFO_DIR "/etc/dhcpc" +#define DHCP_INFO_DIR "/etc/dhcpc" #include <stdio.h> #include <stdlib.h> Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ refresh(); } /** * Set status * @param newStatus - the new status * emit updateInterface */ void Interface::setStatus(bool newStatus){ if(status != newStatus){ status = newStatus; refresh(); } }; /** * Set if attached or not (802.11 card pulled out for example) * @param isAttached - if attached * emit updateInterface @@ -150,49 +150,49 @@ bool Interface::refresh(){ int ipl = line.find("inet addr"); int space = line.find(" ", ipl+10); ip = line.mid(ipl+10, space-ipl-10); } if(line.contains("Mask")){ int mask = line.find("Mask"); subnetMask = line.mid(mask+5, line.length()); } if(line.contains("Bcast")){ int mask = line.find("Bcast"); int space = line.find(" ", mask+6); broadcast = line.mid(mask+6, space-mask-6); } } file.close(); QFile::remove(fileName); // DHCP TESTING // reset DHCP info dhcpServerIp = ""; leaseObtained = ""; leaseExpires = ""; dhcp = false; - QString dhcpDirectory(HDCP_INFO_DIR); + QString dhcpDirectory(DHCP_INFO_DIR); QDir d(dhcpDirectory); if(!d.exists(dhcpDirectory)) dhcpDirectory = "/var/run"; // See if we have QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); // If there is no DHCP information then exit now with no errors. if(!QFile::exists(dhcpFile)){ emit(updateInterface(this)); return true; } file.setName(dhcpFile); if (!file.open(IO_ReadOnly)){ qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); return false; } // leaseTime and renewalTime and used if pid and deamon exe can be accessed. int leaseTime = 0; int renewalTime = 0; stream.setDevice( &file ); while ( !stream.eof() ) { diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 9d81ab1..c86acdc 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -57,66 +57,68 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) ) { // file opened successfully
QTextStream stream( &file ); // use a text stream
while ( !stream.eof() ) { // until end of file...
QString line = stream.readLine(); // line of text excluding '\n'
if(line.contains("SCHEME")){
line = line.mid(7, line.length());
currentProfileLabel->setText(line);
break;
}
}
file.close();
}
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
+ qDebug("start Saving mainwindow");
// Save profiles.
Config cfg("NetworkSetup");
cfg.setGroup("General");
cfg.writeEntry("Profiles", profiles.join(" "));
// Delete all interfaces that don't have owners.
QMap<Interface*, QListViewItem*>::Iterator iIt;
for( iIt = items.begin(); iIt != items.end(); ++iIt ){
if(iIt.key()->getModuleOwner() == NULL)
delete iIt.key();
}
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
delete it.data();
}
+ qDebug("done Saving mainwindow");
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(QString path){
//qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
loadPlugin(path + "/" + fi->fileName());
}
++it;
}
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index ef4ba8f..e545bd1 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp @@ -136,40 +136,40 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ // gather link quality from /proc/net/wireless if(!QFile::exists(PROCNETWIRELESS)) return false; char c; QString status; QString name; QFile wfile( PROCNETWIRELESS ); if(!wfile.open( IO_ReadOnly )) return false; QTextStream wstream( &wfile ); wstream.readLine(); // skip the first two lines wstream.readLine(); // because they only contain headers while(!wstream.atEnd()){ wstream >> name >> status >> quality >> c >> signal >> c >> noise; if(name == QString("%1:").arg(interface)){ if ( quality > 92 ) qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); - qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); + //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; quality = ( quality*100 ) / 92; return true; } } qDebug("WExtensions::statsCard no longer present."); quality = -1; signal = IW_LOWER; noise = IW_LOWER; return false; } // wextensions.cpp diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index ea19207..94c7518 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -1,43 +1,43 @@ #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( QWidget* parent, const char* name):WLAN(parent, name){ +WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){ config = new Config("wireless"); 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 ); diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index 73e753c..7507c54 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp @@ -1,118 +1,118 @@ #include "wlanmodule.h" #include "wlanimp.h" #include "info.h" #include "wextensions.h" #include <qlabel.h> #include <qprogressbar.h> /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { - // get output from iwconfig } /** */ WLANModule::~WLANModule(){ Interface *i; for ( i=list.first(); i != 0; i=list.next() ) - delete i; + 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; - //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ - i->setHardwareName("802.11b"); - list.append(i); - return true; - //} - //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. */ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); (*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(Interface *i, QTabWidget **tabWidget){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; - - WlanInfo *info = new WlanInfo(0, "wireless info"); + + WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); (*tabWidget) = info->tabWidget; info->essidLabel->setText(we.essid()); info->apLabel->setText(we.ap()); info->stationLabel->setText(we.station()); info->modeLabel->setText(we.mode()); info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); int signal = 0; int noise = 0; int quality = 0; we.stats(signal, noise, quality); info->signalProgressBar->setProgress(signal); info->noiseProgressBar->setProgress(noise); info->qualityProgressBar->setProgress(quality); info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); + //WlanInfo info (0, "wireless info", true); + //info.show(); + //return NULL; + 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/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index 7a71142..d61c510 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO @@ -1,11 +1,9 @@ WLAN needs to be re-written to not use Config --remove WLAN Config item --sub class out the wlan info --check if an interface supports wireless extensions before config. +WHERE Is DHCP info stored??? PPP module needs to be written Write a class that parses /proc and not ifconfig -Possible other modules: ipsec, bluetooth +Possible other modules: ipsec, bluetooth, ipchains diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index a84b91f..929b3a1 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp @@ -1,33 +1,33 @@ #include "interface.h" #include <qdatetime.h> #include <qfile.h> #include <qdir.h> #include <qfileinfo.h> #include <qtextstream.h> #define IFCONFIG "/sbin/ifconfig" -#define HDCP_INFO_DIR "/etc/dhcpc" +#define DHCP_INFO_DIR "/etc/dhcpc" #include <stdio.h> #include <stdlib.h> Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ refresh(); } /** * Set status * @param newStatus - the new status * emit updateInterface */ void Interface::setStatus(bool newStatus){ if(status != newStatus){ status = newStatus; refresh(); } }; /** * Set if attached or not (802.11 card pulled out for example) * @param isAttached - if attached * emit updateInterface @@ -150,49 +150,49 @@ bool Interface::refresh(){ int ipl = line.find("inet addr"); int space = line.find(" ", ipl+10); ip = line.mid(ipl+10, space-ipl-10); } if(line.contains("Mask")){ int mask = line.find("Mask"); subnetMask = line.mid(mask+5, line.length()); } if(line.contains("Bcast")){ int mask = line.find("Bcast"); int space = line.find(" ", mask+6); broadcast = line.mid(mask+6, space-mask-6); } } file.close(); QFile::remove(fileName); // DHCP TESTING // reset DHCP info dhcpServerIp = ""; leaseObtained = ""; leaseExpires = ""; dhcp = false; - QString dhcpDirectory(HDCP_INFO_DIR); + QString dhcpDirectory(DHCP_INFO_DIR); QDir d(dhcpDirectory); if(!d.exists(dhcpDirectory)) dhcpDirectory = "/var/run"; // See if we have QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); // If there is no DHCP information then exit now with no errors. if(!QFile::exists(dhcpFile)){ emit(updateInterface(this)); return true; } file.setName(dhcpFile); if (!file.open(IO_ReadOnly)){ qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); return false; } // leaseTime and renewalTime and used if pid and deamon exe can be accessed. int leaseTime = 0; int renewalTime = 0; stream.setDevice( &file ); while ( !stream.eof() ) { diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 9d81ab1..c86acdc 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -57,66 +57,68 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) ) { // file opened successfully
QTextStream stream( &file ); // use a text stream
while ( !stream.eof() ) { // until end of file...
QString line = stream.readLine(); // line of text excluding '\n'
if(line.contains("SCHEME")){
line = line.mid(7, line.length());
currentProfileLabel->setText(line);
break;
}
}
file.close();
}
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
+ qDebug("start Saving mainwindow");
// Save profiles.
Config cfg("NetworkSetup");
cfg.setGroup("General");
cfg.writeEntry("Profiles", profiles.join(" "));
// Delete all interfaces that don't have owners.
QMap<Interface*, QListViewItem*>::Iterator iIt;
for( iIt = items.begin(); iIt != items.end(); ++iIt ){
if(iIt.key()->getModuleOwner() == NULL)
delete iIt.key();
}
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
delete it.data();
}
+ qDebug("done Saving mainwindow");
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(QString path){
//qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
loadPlugin(path + "/" + fi->fileName());
}
++it;
}
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index ef4ba8f..e545bd1 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp @@ -136,40 +136,40 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ // gather link quality from /proc/net/wireless if(!QFile::exists(PROCNETWIRELESS)) return false; char c; QString status; QString name; QFile wfile( PROCNETWIRELESS ); if(!wfile.open( IO_ReadOnly )) return false; QTextStream wstream( &wfile ); wstream.readLine(); // skip the first two lines wstream.readLine(); // because they only contain headers while(!wstream.atEnd()){ wstream >> name >> status >> quality >> c >> signal >> c >> noise; if(name == QString("%1:").arg(interface)){ if ( quality > 92 ) qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); - qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); + //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; quality = ( quality*100 ) / 92; return true; } } qDebug("WExtensions::statsCard no longer present."); quality = -1; signal = IW_LOWER; noise = IW_LOWER; return false; } // wextensions.cpp diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index ea19207..94c7518 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -1,43 +1,43 @@ #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( QWidget* parent, const char* name):WLAN(parent, name){ +WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){ config = new Config("wireless"); 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 ); diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 73e753c..7507c54 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -1,118 +1,118 @@ #include "wlanmodule.h" #include "wlanimp.h" #include "info.h" #include "wextensions.h" #include <qlabel.h> #include <qprogressbar.h> /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { - // get output from iwconfig } /** */ WLANModule::~WLANModule(){ Interface *i; for ( i=list.first(); i != 0; i=list.next() ) - delete i; + 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; - //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ - i->setHardwareName("802.11b"); - list.append(i); - return true; - //} - //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. */ QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); (*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(Interface *i, QTabWidget **tabWidget){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; - - WlanInfo *info = new WlanInfo(0, "wireless info"); + + WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); (*tabWidget) = info->tabWidget; info->essidLabel->setText(we.essid()); info->apLabel->setText(we.ap()); info->stationLabel->setText(we.station()); info->modeLabel->setText(we.mode()); info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); int signal = 0; int noise = 0; int quality = 0; we.stats(signal, noise, quality); info->signalProgressBar->setProgress(signal); info->noiseProgressBar->setProgress(noise); info->qualityProgressBar->setProgress(quality); info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); + //WlanInfo info (0, "wireless info", true); + //info.show(); + //return NULL; + 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; } |