summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
authorbenmeyer <benmeyer>2002-09-30 19:41:41 (UTC)
committer benmeyer <benmeyer>2002-09-30 19:41:41 (UTC)
commita0f88d7d0fb0ffaf8d1aa7b753b0d48ee344e34f (patch) (unidiff)
tree10e1141777f657881af01cab036962c128109ec2 /noncore/settings/networksettings/mainwindowimp.cpp
parentd49bd63f3b15795a1ee2497960f00eb3fb075e69 (diff)
downloadopie-a0f88d7d0fb0ffaf8d1aa7b753b0d48ee344e34f.zip
opie-a0f88d7d0fb0ffaf8d1aa7b753b0d48ee344e34f.tar.gz
opie-a0f88d7d0fb0ffaf8d1aa7b753b0d48ee344e34f.tar.bz2
ui cleanup with groupboxes
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 2f821a9..0f48a4b 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,14 +1,14 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addserviceimp.h" 2#include "addserviceimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h"
6#include "kprocess.h" 5#include "kprocess.h"
7#include "module.h" 6#include "module.h"
8 7
8
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qtabwidget.h> 10#include <qtabwidget.h>
11#include <qlistbox.h> 11#include <qlistbox.h>
12#include <qlistview.h> 12#include <qlistview.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qlabel.h> 14#include <qlabel.h>
@@ -28,17 +28,12 @@
28// For library loading. 28// For library loading.
29#include <dlfcn.h> 29#include <dlfcn.h>
30 30
31#define TEMP_ALL "/tmp/ifconfig-a" 31#define TEMP_ALL "/tmp/ifconfig-a"
32#define TEMP_UP "/tmp/ifconfig" 32#define TEMP_UP "/tmp/ifconfig"
33 33
34#define NO_SELECT_ERROR_AND_RETURN { \
35 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
36 return; \
37}
38
39MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 34MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
40 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 35 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
41 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 36 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
42 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 37 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
43 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 38 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
44 39
@@ -78,22 +73,40 @@ MainWindowImp::~MainWindowImp(){
78 Config cfg("NetworkSetup"); 73 Config cfg("NetworkSetup");
79 cfg.writeEntry("Profiles", profiles.join(" ")); 74 cfg.writeEntry("Profiles", profiles.join(" "));
80 } 75 }
81} 76}
82 77
83void MainWindowImp::loadModules(QString path){ 78void MainWindowImp::loadModules(QString path){
79 qDebug(path.latin1());
80 QDir d;
81 d.setPath(path);
82 if(!d.exists()){
83 qDebug("MainWindowImp:: Path doesn't exists");
84 return;
85 }
86 d.setFilter( QDir::Files | QDir::NoSymLinks );
87 const QFileInfoList *list = d.entryInfoList();
88 QFileInfoListIterator it( *list );
89 QFileInfo *fi;
90 while ( (fi=it.current()) ) {
91 if(fi->fileName().contains(".so")){
92 qDebug("Found");
93 Module *foo = loadPlugin(path + "/" + fi->fileName());
94 }
95 ++it;
96 }
84} 97}
85 98
86/** 99/**
87 * Attempt to load a function and resolve a function. 100 * Attempt to load a function and resolve a function.
88 * @param pluginFileName - the name of the file in which to attempt to load 101 * @param pluginFileName - the name of the file in which to attempt to load
89 * @param resolveString - function pointer to resolve 102 * @param resolveString - function pointer to resolve
90 * @return pointer to the function with name resolveString or NULL 103 * @return pointer to the function with name resolveString or NULL
91 */ 104 */
92Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 105Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
93 //qDebug(pluginFileName.latin1()); 106 qDebug(pluginFileName.latin1());
94 QLibrary *lib = new QLibrary(pluginFileName); 107 QLibrary *lib = new QLibrary(pluginFileName);
95 void *functionPointer = lib->resolve(resolveString); 108 void *functionPointer = lib->resolve(resolveString);
96 if( !functionPointer ){ 109 if( !functionPointer ){
97 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 110 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
98 delete lib; 111 delete lib;
99 return NULL; 112 return NULL;
@@ -109,40 +122,12 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
109 122
110 // Store for reference 123 // Store for reference
111 libraries.insert(object, lib); 124 libraries.insert(object, lib);
112 return object; 125 return object;
113} 126}
114 127
115/*
116QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
117 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
118 QString path = DirStr + "plugins";
119 QDir d(path);
120 d.setFilter( QDir::Files | QDir::Hidden );
121
122 QMap<QObject*, QLibrary*>::Iterator libraryIt;
123 QList<QString> rlist;
124 rlist.setAutoDelete(false);
125
126 const QFileInfoList *list = d.entryInfoList();
127 QFileInfoListIterator it( *list );
128 QFileInfo *fi;
129 while ( (fi=it.current()) ) {
130 if(fi->fileName().contains(".so")){
131 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
132 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
133 QString *s = new QString(path + "/" + fi->fileName());
134 rlist.append(s);
135 }
136 }
137 ++it;
138 }
139 return rlist;
140}
141*/
142
143/** 128/**
144 * The Add button was clicked. Bring up the add dialog and if OK is hit 129 * The Add button was clicked. Bring up the add dialog and if OK is hit
145 * load the plugin and append it to the list 130 * load the plugin and append it to the list
146 */ 131 */
147void MainWindowImp::addClicked(){ 132void MainWindowImp::addClicked(){
148 // Now that we have a list of all of the protocals, list them. 133 // Now that we have a list of all of the protocals, list them.
@@ -158,13 +143,16 @@ void MainWindowImp::addClicked(){
158/** 143/**
159 * Prompt the user to see if they really want to do this. 144 * Prompt the user to see if they really want to do this.
160 * If they do then remove from the list and unload. 145 * If they do then remove from the list and unload.
161 */ 146 */
162void MainWindowImp::removeClicked(){ 147void MainWindowImp::removeClicked(){
163 QListViewItem *item = serviceList->currentItem(); 148 QListViewItem *item = serviceList->currentItem();
164 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 149 if(item == NULL) {
150 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
151 return;
152 }
165 153
166 if(modules.find(interfaceItems[item]) == modules.end()){ 154 if(modules.find(interfaceItems[item]) == modules.end()){
167 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 155 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
168 } 156 }
169 else{ 157 else{
170 // Try to remove. 158 // Try to remove.
@@ -175,13 +163,16 @@ void MainWindowImp::removeClicked(){
175/** 163/**
176 * See if there is a configuration for the selected protocal. 164 * See if there is a configuration for the selected protocal.
177 * Prompt with errors. 165 * Prompt with errors.
178 */ 166 */
179void MainWindowImp::configureClicked(){ 167void MainWindowImp::configureClicked(){
180 QListViewItem *item = serviceList->currentItem(); 168 QListViewItem *item = serviceList->currentItem();
181 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 169 if(item == NULL){
170 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
171 return;
172 }
182 173
183 if(modules.find(interfaceItems[item]) == modules.end()){ 174 if(modules.find(interfaceItems[item]) == modules.end()){
184 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); 175 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
185 conf->showMaximized(); 176 conf->showMaximized();
186 conf->show(); 177 conf->show();
187 } 178 }
@@ -194,14 +185,17 @@ void MainWindowImp::configureClicked(){
194/** 185/**
195 * Pull up the information about the selected interface 186 * Pull up the information about the selected interface
196 * Report an error 187 * Report an error
197 */ 188 */
198void MainWindowImp::informationClicked(){ 189void MainWindowImp::informationClicked(){
199 QListViewItem *item = serviceList->currentItem(); 190 QListViewItem *item = serviceList->currentItem();
200 if(item == NULL)NO_SELECT_ERROR_AND_RETURN 191 if(item == NULL){
201 192 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
193 return;
194 }
195
202 if(modules.find(interfaceItems[item]) == modules.end()){ 196 if(modules.find(interfaceItems[item]) == modules.end()){
203 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); 197 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
204 i->showMaximized(); 198 i->showMaximized();
205 i->show(); 199 i->show();
206 } 200 }
207 else{ 201 else{
@@ -308,12 +302,16 @@ void MainWindowImp::updateInterface(Interface *i){
308 QPixmap status = (Resource::loadPixmap(statusImage)); 302 QPixmap status = (Resource::loadPixmap(statusImage));
309 item->setPixmap(0, status); 303 item->setPixmap(0, status);
310 304
311 QString typeName = "lan"; 305 QString typeName = "lan";
312 if(i->getHardwareName().contains("Local Loopback")) 306 if(i->getHardwareName().contains("Local Loopback"))
313 typeName = "lo"; 307 typeName = "lo";
308 if(i->getInterfaceName().contains("irda"))
309 typeName = "irda";
310 if(i->getInterfaceName().contains("wlan"))
311 typeName = "wlan";
314 QPixmap type = (Resource::loadPixmap(typeName)); 312 QPixmap type = (Resource::loadPixmap(typeName));
315 item->setPixmap(1, type); 313 item->setPixmap(1, type);
316 314
317 item->setText(2, i->getHardwareName()); 315 item->setText(2, i->getHardwareName());
318 316
319} 317}