summaryrefslogtreecommitdiff
path: root/noncore/net/networksetup/mainwindowimp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 2f821a9..0f48a4b 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,14 +1,14 @@
#include "mainwindowimp.h"
#include "addserviceimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
-#include "interface.h"
#include "kprocess.h"
#include "module.h"
+
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qlistbox.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
@@ -28,17 +28,12 @@
// For library loading.
#include <dlfcn.h>
#define TEMP_ALL "/tmp/ifconfig-a"
#define TEMP_UP "/tmp/ifconfig"
-#define NO_SELECT_ERROR_AND_RETURN { \
- QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
- return; \
-}
-
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
@@ -78,22 +73,40 @@ MainWindowImp::~MainWindowImp(){
Config cfg("NetworkSetup");
cfg.writeEntry("Profiles", profiles.join(" "));
}
}
void MainWindowImp::loadModules(QString path){
+ qDebug(path.latin1());
+ QDir d;
+ d.setPath(path);
+ if(!d.exists()){
+ qDebug("MainWindowImp:: Path doesn't exists");
+ return;
+ }
+ 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")){
+ qDebug("Found");
+ Module *foo = 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(pluginFileName.latin1());
+ qDebug(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;
@@ -109,40 +122,12 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
// Store for reference
libraries.insert(object, lib);
return object;
}
-/*
-QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
- QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
- QString path = DirStr + "plugins";
- QDir d(path);
- d.setFilter( QDir::Files | QDir::Hidden );
-
- QMap<QObject*, QLibrary*>::Iterator libraryIt;
- QList<QString> rlist;
- rlist.setAutoDelete(false);
-
- const QFileInfoList *list = d.entryInfoList();
- QFileInfoListIterator it( *list );
- QFileInfo *fi;
- while ( (fi=it.current()) ) {
- if(fi->fileName().contains(".so")){
- for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
- if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
- QString *s = new QString(path + "/" + fi->fileName());
- rlist.append(s);
- }
- }
- ++it;
- }
- return rlist;
-}
-*/
-
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
// Now that we have a list of all of the protocals, list them.
@@ -158,13 +143,16 @@ void MainWindowImp::addClicked(){
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
void MainWindowImp::removeClicked(){
QListViewItem *item = serviceList->currentItem();
- if(item == NULL) NO_SELECT_ERROR_AND_RETURN
+ if(item == NULL) {
+ QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ return;
+ }
if(modules.find(interfaceItems[item]) == modules.end()){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
}
else{
// Try to remove.
@@ -175,13 +163,16 @@ void MainWindowImp::removeClicked(){
/**
* See if there is a configuration for the selected protocal.
* Prompt with errors.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = serviceList->currentItem();
- if(item == NULL) NO_SELECT_ERROR_AND_RETURN
+ if(item == NULL){
+ QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ return;
+ }
if(modules.find(interfaceItems[item]) == modules.end()){
InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
conf->showMaximized();
conf->show();
}
@@ -194,14 +185,17 @@ void MainWindowImp::configureClicked(){
/**
* Pull up the information about the selected interface
* Report an error
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = serviceList->currentItem();
- if(item == NULL)NO_SELECT_ERROR_AND_RETURN
-
+ if(item == NULL){
+ QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ return;
+ }
+
if(modules.find(interfaceItems[item]) == modules.end()){
InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
i->showMaximized();
i->show();
}
else{
@@ -308,12 +302,16 @@ void MainWindowImp::updateInterface(Interface *i){
QPixmap status = (Resource::loadPixmap(statusImage));
item->setPixmap(0, status);
QString typeName = "lan";
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
+ if(i->getInterfaceName().contains("irda"))
+ typeName = "irda";
+ if(i->getInterfaceName().contains("wlan"))
+ typeName = "wlan";
QPixmap type = (Resource::loadPixmap(typeName));
item->setPixmap(1, type);
item->setText(2, i->getHardwareName());
}