summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
authorbenmeyer <benmeyer>2002-09-30 14:46:34 (UTC)
committer benmeyer <benmeyer>2002-09-30 14:46:34 (UTC)
commitd79ae2969e74b1caa8e562910715df4ffe1739b3 (patch) (side-by-side diff)
tree1808d0d3747581ca999ec42b4bb029471a1aa199 /noncore/settings/networksettings/mainwindowimp.cpp
parent9965bd5c49ff2f22d640d132ac343fdec97b3fb4 (diff)
downloadopie-d79ae2969e74b1caa8e562910715df4ffe1739b3.zip
opie-d79ae2969e74b1caa8e562910715df4ffe1739b3.tar.gz
opie-d79ae2969e74b1caa8e562910715df4ffe1739b3.tar.bz2
Fixed compiler warnings
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 3c13143..ad9362f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,82 +1,93 @@
#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 <qdir.h>
#include <qtabwidget.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qlistbox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qlist.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qlistview.h>
#include <qheader.h>
// 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()));
// Make sure we have a plugin directory to scan.
QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
QDir pluginDir( DirStr );
pluginDir.mkdir( DirStr );
pluginDir.mkdir( ( DirStr + "plugins/" ) );
QString path = DirStr + "plugins";
pluginDir.setPath(path);
if(!pluginDir.exists()){
qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
return;
}
// Load any saved services.
loadModules(path);
getInterfaceList();
serviceList->header()->hide();
+
+
+ Config cfg("NetworkSetup");
+ profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
}
/**
- * Deconstructor. Unload libraries and save.
+ * Deconstructor. Unload libraries and save profile list.
*/
MainWindowImp::~MainWindowImp(){
+ if(profiles.count() > 1){
+ Config cfg("NetworkSetup");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+ }
}
void MainWindowImp::loadModules(QString path){
}
/**
* 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());
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;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
@@ -231,49 +242,49 @@ void MainWindowImp::jobDone(KProcess *process){
QString interfaceName = line.mid(0, space);
Interface *i;
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(interfaceName, false);
else
i = new Interface(interfaceName, true);
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
i->setStatus(true);
}
i->setAttached(true);
i->setInterfaceName(interfaceName);
QString hardName = "Ethernet";
int hardwareName = line.find("Link encap:");
int macAddress = line.find("HWaddr");
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
file.close();
QFile::remove(fileName);
}
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// See if we already have it
if(items.find(i) == items.end()){
item = new QListViewItem(serviceList, "", "", "");
// See if you can't find a module owner for this interface
//EmployeeMap::Iterator it;
//for( it = map.begin(); it != map.end(); ++it )
// printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
items.insert(i, item);
interfaceItems.insert(item, i);
}