summaryrefslogtreecommitdiff
path: root/noncore/net/networksetup/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp28
1 files changed, 7 insertions, 21 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index f9ca83b..b9fff56 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,24 +1,23 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6 6
7#include "module.h" 7#include "module.h"
8 8
9#include "kprocess.h" 9#include "kprocess.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qtabwidget.h>
13#include <qlistbox.h> 12#include <qlistbox.h>
14#include <qlineedit.h> 13#include <qlineedit.h>
15#include <qlistview.h> 14#include <qlistview.h>
16#include <qheader.h> 15#include <qheader.h>
17#include <qlabel.h> 16#include <qlabel.h>
18 17
19#include <qmainwindow.h> 18#include <qmainwindow.h>
20#include <qmessagebox.h> 19#include <qmessagebox.h>
21 20
22#include <qpe/config.h> 21#include <qpe/config.h>
23#include <qpe/qlibrary.h> 22#include <qpe/qlibrary.h>
24#include <qpe/resource.h> 23#include <qpe/resource.h>
@@ -86,24 +85,25 @@ MainWindowImp::~MainWindowImp(){
86 // Delete all interfaces that don't have owners. 85 // Delete all interfaces that don't have owners.
87 QMap<Interface*, QListViewItem*>::Iterator iIt; 86 QMap<Interface*, QListViewItem*>::Iterator iIt;
88 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 87 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
89 if(iIt.key()->getModuleOwner() == NULL) 88 if(iIt.key()->getModuleOwner() == NULL)
90 delete iIt.key(); 89 delete iIt.key();
91 } 90 }
92 91
93 // Delete Modules and Libraries 92 // Delete Modules and Libraries
94 QMap<Module*, QLibrary*>::Iterator it; 93 QMap<Module*, QLibrary*>::Iterator it;
95 for( it = libraries.begin(); it != libraries.end(); ++it ){ 94 for( it = libraries.begin(); it != libraries.end(); ++it ){
96 delete it.key(); 95 delete it.key();
97 // I wonder why I can't delete the libraries 96 // I wonder why I can't delete the libraries
97 // What fucking shit this is.
98 //delete it.data(); 98 //delete it.data();
99 } 99 }
100} 100}
101 101
102/** 102/**
103 * Load all modules that are found in the path 103 * Load all modules that are found in the path
104 * @param path a directory that is scaned for any plugins that can be loaded 104 * @param path a directory that is scaned for any plugins that can be loaded
105 * and attempts to load them 105 * and attempts to load them
106 */ 106 */
107void MainWindowImp::loadModules(QString path){ 107void MainWindowImp::loadModules(QString path){
108 //qDebug(path.latin1()); 108 //qDebug(path.latin1());
109 QDir d(path); 109 QDir d(path);
@@ -212,100 +212,86 @@ void MainWindowImp::removeClicked(){
212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
213 else{ 213 else{
214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
215 // TODO memory managment.... 215 // TODO memory managment....
216 // who deletes the interface? 216 // who deletes the interface?
217 } 217 }
218 } 218 }
219} 219}
220 220
221/** 221/**
222 * Pull up the configure about the currently selected interface. 222 * Pull up the configure about the currently selected interface.
223 * Report an error if no interface is selected. 223 * Report an error if no interface is selected.
224 * If the interface has a module owner then request its configure with a empty 224 * If the interface has a module owner then request its configure.
225 * tab. If tab is !NULL then append the interfaces setup widget to it.
226 */ 225 */
227void MainWindowImp::configureClicked(){ 226void MainWindowImp::configureClicked(){
228 QListViewItem *item = connectionList->currentItem(); 227 QListViewItem *item = connectionList->currentItem();
229 if(!item){ 228 if(!item){
230 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 229 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
231 return; 230 return;
232 } 231 }
233 232
234 QString currentProfile = currentProfileLabel->text(); 233 QString currentProfile = currentProfileLabel->text();
235 if(profilesList->count() <= 1 || currentProfile == "All"){ 234 if(profilesList->count() <= 1 || currentProfile == "All"){
236 currentProfile = ""; 235 currentProfile = "";
237 } 236 }
238 237
239 Interface *i = interfaceItems[item]; 238 Interface *i = interfaceItems[item];
240 if(i->getModuleOwner()){ 239 if(i->getModuleOwner()){
241 i->getModuleOwner()->setProfile(currentProfile); 240 i->getModuleOwner()->setProfile(currentProfile);
242 QTabWidget *tabWidget = NULL; 241 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
243 QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
244 if(moduleConfigure != NULL){ 242 if(moduleConfigure != NULL){
245 if(tabWidget != NULL){
246 InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
247 configure->setProfile(currentProfile);
248 tabWidget->insertTab(configure, "TCP/IP");
249 }
250 moduleConfigure->showMaximized(); 243 moduleConfigure->showMaximized();
251 moduleConfigure->show(); 244 moduleConfigure->show();
252 return; 245 return;
253 } 246 }
254 } 247 }
255 248
256 InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose); 249 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose);
257 configure->setProfile(currentProfile); 250 //configure->setProfile(currentProfile);
258 configure->showMaximized(); 251 configure->showMaximized();
259 configure->show(); 252 configure->show();
260} 253}
261 254
262/** 255/**
263 * Pull up the information about the currently selected interface. 256 * Pull up the information about the currently selected interface.
264 * Report an error if no interface is selected. 257 * Report an error if no interface is selected.
265 * If the interface has a module owner then request its configure with a empty 258 * If the interface has a module owner then request its configure.
266 * tab. If tab is !NULL then append the interfaces setup widget to it.
267 */ 259 */
268void MainWindowImp::informationClicked(){ 260void MainWindowImp::informationClicked(){
269 QListViewItem *item = connectionList->currentItem(); 261 QListViewItem *item = connectionList->currentItem();
270 if(!item){ 262 if(!item){
271 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 263 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
272 return; 264 return;
273 } 265 }
274 266
275 Interface *i = interfaceItems[item]; 267 Interface *i = interfaceItems[item];
276 if(!i->isAttached()){ 268 if(!i->isAttached()){
277 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 269 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
278 return; 270 return;
279 } 271 }
280 272
281 QStringList list; 273 QStringList list;
282 for(uint i = 0; i < profilesList->count(); i++){ 274 for(uint i = 0; i < profilesList->count(); i++){
283 list.append(profilesList->text(i)); 275 list.append(profilesList->text(i));
284 } 276 }
285 277
286 if(i->getModuleOwner()){ 278 if(i->getModuleOwner()){
287 QTabWidget *tabWidget = NULL; 279 QWidget *moduleInformation = i->getModuleOwner()->information(i);
288 QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
289 if(moduleInformation != NULL){ 280 if(moduleInformation != NULL){
290 if(tabWidget != NULL){
291 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
292 tabWidget->insertTab(information, "TCP/IP");
293 }
294 moduleInformation->showMaximized(); 281 moduleInformation->showMaximized();
295 moduleInformation->show(); 282 moduleInformation->show();
296 return; 283 return;
297 } 284 }
298 } 285 }
299
300 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); 286 InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
301 information->showMaximized(); 287 information->showMaximized();
302 information->show(); 288 information->show();
303} 289}
304 290
305/** 291/**
306 * Aquire the list of active interfaces from ifconfig 292 * Aquire the list of active interfaces from ifconfig
307 * Call ifconfig and ifconfig -a 293 * Call ifconfig and ifconfig -a
308 */ 294 */
309void MainWindowImp::getInterfaceList(){ 295void MainWindowImp::getInterfaceList(){
310 KShellProcess *processAll = new KShellProcess(); 296 KShellProcess *processAll = new KShellProcess();
311 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 297 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;