summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
authorbenmeyer <benmeyer>2002-10-02 17:22:50 (UTC)
committer benmeyer <benmeyer>2002-10-02 17:22:50 (UTC)
commit527e77d8244fb25d0bab39857eebbdfbcbfb807a (patch) (side-by-side diff)
treef3ec7cee3573ef83d8d86f859c7c3de3a8b06b9f /noncore/settings/networksettings/mainwindowimp.cpp
parent6e50141595ec2159d384c2cb9aaee4758eb720ea (diff)
downloadopie-527e77d8244fb25d0bab39857eebbdfbcbfb807a.zip
opie-527e77d8244fb25d0bab39857eebbdfbcbfb807a.tar.gz
opie-527e77d8244fb25d0bab39857eebbdfbcbfb807a.tar.bz2
Add Connection function more filled in
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp205
1 files changed, 106 insertions, 99 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 89dac6f..66ec8b5 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,8 +1,8 @@
#include "mainwindowimp.h"
-#include "addserviceimp.h"
+#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
-#include "kprocess.h"
#include "module.h"
+#include "kprocess.h"
@@ -27,5 +27,2 @@
-// For library loading.
-#include <dlfcn.h>
-
#define TEMP_ALL "/tmp/ifconfig-a"
@@ -33,7 +30,7 @@
-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()));
+MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
+ 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()));
@@ -43,18 +40,6 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
- // 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);
+ // Load connections.
+ loadModules(QDir::homeDirPath() + "/.networksetup/plugins");
getInterfaceList();
- serviceList->header()->hide();
+ connectionList->header()->hide();
@@ -65,2 +50,3 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
profilesList->insertItem((*it));
+ advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
}
@@ -68,5 +54,6 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
/**
- * Deconstructor. Unload libraries and save profile list.
+ * Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
+ // Save profiles.
if(profiles.count() > 1){
@@ -75,12 +62,22 @@ MainWindowImp::~MainWindowImp(){
}
+ // 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;
- d.setPath(path);
- if(!d.exists()){
- qDebug("MainWindowImp:: Path doesn't exists");
+ QDir d(path);
+ if(!d.exists())
return;
- }
+
+ // Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
@@ -91,4 +88,3 @@ void MainWindowImp::loadModules(QString path){
if(fi->fileName().contains(".so")){
- qDebug("Found");
- Module *foo = loadPlugin(path + "/" + fi->fileName());
+ loadPlugin(path + "/" + fi->fileName());
}
@@ -105,3 +101,3 @@ void MainWindowImp::loadModules(QString path){
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
- qDebug(pluginFileName.latin1());
+ qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
QLibrary *lib = new QLibrary(pluginFileName);
@@ -122,3 +118,3 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
- // Store for reference
+ // Store for deletion later
libraries.insert(object, lib);
@@ -132,10 +128,21 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
void MainWindowImp::addClicked(){
- // Now that we have a list of all of the protocals, list them.
- {
- QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
+ QMap<Module*, QLibrary*>::Iterator it;
+ QMap<QString, QString> list;
+ list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
+ list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
+ for( it = libraries.begin(); it != libraries.end(); ++it ){
+ if(it.key())
+ (it.key())->possibleNewInterfaces(list);
+ }
+ // See if the list has anything that we can add.
+ if(list.count() == 0){
+ QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
return;
}
- AddServiceImp service(this, "AddService", true);
- service.showMaximized();
- service.exec();
+ AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
+ addNewConnection.addConnections(list);
+ addNewConnection.showMaximized();
+ if(QDialog::Accepted == addNewConnection.exec()){
+
+ }
}
@@ -147,3 +154,3 @@ void MainWindowImp::addClicked(){
void MainWindowImp::removeClicked(){
- QListViewItem *item = serviceList->currentItem();
+ QListViewItem *item = connectionList->currentItem();
if(item == NULL) {
@@ -163,36 +170,32 @@ void MainWindowImp::removeClicked(){
/**
- * See if there is a configuration for the selected protocal.
- * Prompt with errors.
+ * Pull up the configure about the currently selected interface.
+ * Report an error if no interface is selected.
+ * If the interface has a module owner then request its configure with a empty
+ * tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::configureClicked(){
- QListViewItem *item = serviceList->currentItem();
- if(item == NULL){
- QMessageBox::information(this, "Error","Please select an interface.", "Ok");
- return;
+ QListViewItem *item = connectionList->currentItem();
+ if(!item){
+ QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
+ return;
}
-
- if((interfaceItems[item])->getModuleOwner() == NULL){
- InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
- conf->showMaximized();
- conf->show();
- }
- else{
- QTabWidget *t = NULL;
- QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t);
- if(conf != NULL){
- qDebug("Conf found");
- if(t != NULL){
- qDebug("Adding Interface");
- InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true);
- t->insertTab(i, "TCP/IP");
+
+ Interface *i = interfaceItems[item];
+ if(i->getModuleOwner()){
+ QTabWidget *tabWidget = NULL;
+ QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
+ if(moduleConfigure != NULL){
+ if(tabWidget != NULL){
+ InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
+ tabWidget->insertTab(configure, "TCP/IP");
}
- conf->showMaximized();
- conf->show();
- }
- else{
- InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true);
- i->showMaximized();
- i->show();
+ moduleConfigure->showMaximized();
+ moduleConfigure->show();
+ return;
}
}
+
+ InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->showMaximized();
+ configure->show();
}
@@ -200,35 +203,32 @@ void MainWindowImp::configureClicked(){
/**
- * Pull up the information about the selected interface
- * Report an error
+ * Pull up the information about the currently selected interface.
+ * Report an error if no interface is selected.
+ * If the interface has a module owner then request its configure with a empty
+ * tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::informationClicked(){
- QListViewItem *item = serviceList->currentItem();
- if(item == NULL){
- QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ QListViewItem *item = connectionList->currentItem();
+ if(!item){
+ QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
- }
-
- if( (interfaceItems[item])->getModuleOwner() == NULL){
- InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
- i->showMaximized();
- i->show();
- }
- else{
- QTabWidget *t = NULL;
- QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t);
- if(conf != NULL){
- if(t){
- qDebug("Adding Interface");
- InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
- t->insertTab(i, "TCP/IP");
+ }
+
+ Interface *i = interfaceItems[item];
+ if(i->getModuleOwner()){
+ QTabWidget *tabWidget = NULL;
+ QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
+ if(moduleInformation != NULL){
+ if(tabWidget != NULL){
+ InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
+ tabWidget->insertTab(information, "TCP/IP");
}
- conf->showMaximized();
- conf->show();
+ moduleInformation->showMaximized();
+ moduleInformation->show();
+ return;
}
- else{
- InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true);
- i->showMaximized();
- i->show();
- }
- }
+ }
+
+ InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
+ information->showMaximized();
+ information->show();
}
@@ -274,2 +274,6 @@ void MainWindowImp::jobDone(KProcess *process){
QString interfaceName = line.mid(0, space);
+ if(!advancedUserMode){
+ if(interfaceName == "lo")
+ break;
+ }
Interface *i;
@@ -308,2 +312,5 @@ void MainWindowImp::jobDone(KProcess *process){
+/**
+ *
+ */
void MainWindowImp::updateInterface(Interface *i){
@@ -313,3 +320,3 @@ void MainWindowImp::updateInterface(Interface *i){
if(items.find(i) == items.end()){
- item = new QListViewItem(serviceList, "", "", "");
+ item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface