summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp7
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp5
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp7
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp5
4 files changed, 18 insertions, 6 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 843f630..9d81ab1 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -38,96 +38,103 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
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(){
// 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();
}
}
/**
* 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;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
//qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index cbb520d..24cb1cd 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -1,124 +1,123 @@
#include "wlanmodule.h"
-#include <qpe/config.h>
#include "wlanimp.h"
#include "info.h"
-
#include <arpa/inet.h>
#include <sys/socket.h>
#include <linux/if_ether.h>
#include <netinet/ip.h>
#include <sys/ioctl.h>
#include <linux/wireless.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <qlabel.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("802.11b");
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(Interface *i, QTabWidget **tabWidget){
- WLANImp *wlanconfig = new WLANImp( );
+ 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){
+ return NULL;
WlanInfo *info = new WlanInfo(0, "wireless info");
(*tabWidget) = info->tabWidget;
struct ifreq ifr;
struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
int fd = socket( AF_INET, SOCK_DGRAM, 0 );
const char* buffer[200];
struct iwreq iwr;
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)
QString n = (i->getInterfaceName());
const char* iname = n.latin1();
strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
int result = ioctl( fd, SIOCGIWESSID, &iwr );
if ( result == 0 ){
//hasWirelessExtensions = true;
iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
info->essidLabel->setText(QString(iwr.u.essid.pointer));
}
else
return info;
//info->essidLabel->setText("*** Unknown ***");
// Address of associated access-point
result = ioctl( fd, SIOCGIWAP, &iwr );
if ( result == 0 ){
QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
iwr.u.ap_addr.sa_data[0]&0xff,
iwr.u.ap_addr.sa_data[1]&0xff,
iwr.u.ap_addr.sa_data[2]&0xff,
iwr.u.ap_addr.sa_data[3]&0xff,
iwr.u.ap_addr.sa_data[4]&0xff,
iwr.u.ap_addr.sa_data[5]&0xff );
info->apLabel->setText(foo);
}
else info->apLabel->setText("*** Unknown ***");
iwr.u.data.pointer = (caddr_t) buffer;
iwr.u.data.length = IW_ESSID_MAX_SIZE;
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 843f630..9d81ab1 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -38,96 +38,103 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
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(){
// 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();
}
}
/**
* 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;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
//qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index cbb520d..24cb1cd 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,124 +1,123 @@
#include "wlanmodule.h"
-#include <qpe/config.h>
#include "wlanimp.h"
#include "info.h"
-
#include <arpa/inet.h>
#include <sys/socket.h>
#include <linux/if_ether.h>
#include <netinet/ip.h>
#include <sys/ioctl.h>
#include <linux/wireless.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <qlabel.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("802.11b");
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(Interface *i, QTabWidget **tabWidget){
- WLANImp *wlanconfig = new WLANImp( );
+ 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){
+ return NULL;
WlanInfo *info = new WlanInfo(0, "wireless info");
(*tabWidget) = info->tabWidget;
struct ifreq ifr;
struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.ifr_addr;
int fd = socket( AF_INET, SOCK_DGRAM, 0 );
const char* buffer[200];
struct iwreq iwr;
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)
QString n = (i->getInterfaceName());
const char* iname = n.latin1();
strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname );
int result = ioctl( fd, SIOCGIWESSID, &iwr );
if ( result == 0 ){
//hasWirelessExtensions = true;
iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length-1] = '\0';
info->essidLabel->setText(QString(iwr.u.essid.pointer));
}
else
return info;
//info->essidLabel->setText("*** Unknown ***");
// Address of associated access-point
result = ioctl( fd, SIOCGIWAP, &iwr );
if ( result == 0 ){
QString foo = foo.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
iwr.u.ap_addr.sa_data[0]&0xff,
iwr.u.ap_addr.sa_data[1]&0xff,
iwr.u.ap_addr.sa_data[2]&0xff,
iwr.u.ap_addr.sa_data[3]&0xff,
iwr.u.ap_addr.sa_data[4]&0xff,
iwr.u.ap_addr.sa_data[5]&0xff );
info->apLabel->setText(foo);
}
else info->apLabel->setText("*** Unknown ***");
iwr.u.data.pointer = (caddr_t) buffer;
iwr.u.data.length = IW_ESSID_MAX_SIZE;