summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 2d714ca..f74cf87 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -8,16 +8,17 @@
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qlistview.h> 11#include <qlistview.h>
12#include <qheader.h> 12#include <qheader.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qpe/qcopenvelope_qws.h> 14#include <qpe/qcopenvelope_qws.h>
15#include <qtabwidget.h> // in order to disable the profiles tab 15#include <qtabwidget.h> // in order to disable the profiles tab
16#include <qpe/qpeapplication.h>
16 17
17#include <qmessagebox.h> 18#include <qmessagebox.h>
18 19
19#ifdef QWS 20#ifdef QWS
20 #include <qpe/config.h> 21 #include <qpe/config.h>
21 #include <qpe/qlibrary.h> 22 #include <qpe/qlibrary.h>
22 #include <qpe/resource.h> 23 #include <qpe/resource.h>
23 #include <qpe/qpeapplication.h> 24 #include <qpe/qpeapplication.h>
@@ -44,45 +45,53 @@
44 45
45#include <net/if.h> 46#include <net/if.h>
46#include <sys/ioctl.h> 47#include <sys/ioctl.h>
47#include <sys/socket.h> 48#include <sys/socket.h>
48 49
49#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 50#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
50#define _PROCNETDEV "/proc/net/dev" 51#define _PROCNETDEV "/proc/net/dev"
51 52
52MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 53MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){
53 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 54 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
54 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 55 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
55 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 56 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
56 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 57 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
57 58
58 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 59 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
59 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 60 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
60 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 61 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
61 62
62 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 63 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
63 64
64 //FIXME: disable profiles for the moment: 65 //FIXME: disable profiles for the moment:
65// tabWidget->setTabEnabled( tab, false ); 66 tabWidget->setTabEnabled( tab, false );
66 67
67 // Load connections. 68 // Load connections.
68 // /usr/local/kde/lib/libinterfaces.la 69 // /usr/local/kde/lib/libinterfaces.la
69#ifdef QWS 70#ifdef QWS
70 loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); 71 loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
71#else 72#else
72 loader = KLibLoader::self(); 73 loader = KLibLoader::self();
73 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 74 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
74#endif 75#endif
75 getAllInterfaces(); 76 getAllInterfaces();
76 77
77 Interfaces i; 78 Interfaces i;
78 QStringList list = i.getInterfaceList(); 79 QStringList list = i.getInterfaceList();
79 QMap<QString, Interface*>::Iterator it; 80 QMap<QString, Interface*>::Iterator it;
80 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 81 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
82 /*
83 * we skipped it in getAllInterfaces now
84 * we need to ignore it as well
85 */
86 if (m_handledIfaces.contains( *ni) ) {
87 qDebug("Not up iface handled by module");
88 continue;
89 }
81 bool found = false; 90 bool found = false;
82 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 91 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
83 if(it.key() == (*ni)) 92 if(it.key() == (*ni))
84 found = true; 93 found = true;
85 } 94 }
86 if(!found){ 95 if(!found){
87 if(!(*ni).contains("_")){ 96 if(!(*ni).contains("_")){
88 Interface *i = new Interface(this, *ni, false); 97 Interface *i = new Interface(this, *ni, false);
@@ -191,16 +200,20 @@ void MainWindowImp::getAllInterfaces(){
191 if((loc = line.find(":")) != -1) { 200 if((loc = line.find(":")) != -1) {
192 ifaces += line.left(loc); 201 ifaces += line.left(loc);
193 } 202 }
194 } 203 }
195 } 204 }
196 205
197 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 206 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
198 int flags = 0; 207 int flags = 0;
208 if ( m_handledIfaces.contains( (*it) ) ) {
209 qDebug(" %s is handled by a module", (*it).latin1() );
210 continue;
211 }
199// int family; 212// int family;
200 i = NULL; 213 i = NULL;
201 214
202 strcpy(ifr.ifr_name, (*it).latin1()); 215 strcpy(ifr.ifr_name, (*it).latin1());
203 216
204 struct ifreq ifcopy; 217 struct ifreq ifcopy;
205 ifcopy = ifr; 218 ifcopy = ifr;
206 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 219 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
@@ -302,16 +315,17 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &
302 if(object == NULL){ 315 if(object == NULL){
303#ifdef DEBUG 316#ifdef DEBUG
304 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 317 qDebug("MainWindowImp: Couldn't create object, but did load library!");
305#endif 318#endif
306 delete lib; 319 delete lib;
307 return NULL; 320 return NULL;
308 } 321 }
309 322
323 m_handledIfaces += object->handledInterfaceNames();
310 // Store for deletion later 324 // Store for deletion later
311 libraries.insert(object, lib); 325 libraries.insert(object, lib);
312 return object; 326 return object;
313 327
314#else 328#else
315 QLibrary *lib = loader->library(pluginFileName); 329 QLibrary *lib = loader->library(pluginFileName);
316 if( !lib || !lib->hasSymbol(resolveString) ){ 330 if( !lib || !lib->hasSymbol(resolveString) ){
317 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 331 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
@@ -421,17 +435,17 @@ void MainWindowImp::configureClicked(){
421 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 435 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
422 if(moduleConfigure != NULL){ 436 if(moduleConfigure != NULL){
423 i->getModuleOwner()->setProfile(currentProfileText); 437 i->getModuleOwner()->setProfile(currentProfileText);
424 moduleConfigure->showMaximized(); 438 moduleConfigure->showMaximized();
425 return; 439 return;
426 } 440 }
427 } 441 }
428 442
429 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); 443 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp );
430 configure->setProfile(currentProfileText); 444 configure->setProfile(currentProfileText);
431 configure->showMaximized(); 445 configure->showMaximized();
432} 446}
433 447
434/** 448/**
435 * Pull up the information about the currently selected interface. 449 * Pull up the information about the currently selected interface.
436 * Report an error if no interface is selected. 450 * Report an error if no interface is selected.
437 * If the interface has a module owner then request its configure. 451 * If the interface has a module owner then request its configure.
@@ -454,17 +468,17 @@ void MainWindowImp::informationClicked(){
454 if(moduleInformation != NULL){ 468 if(moduleInformation != NULL){
455 moduleInformation->showMaximized(); 469 moduleInformation->showMaximized();
456#ifdef DEBUG 470#ifdef DEBUG
457 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 471 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
458#endif 472#endif
459 return; 473 return;
460 } 474 }
461 } 475 }
462 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 476 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
463 information->showMaximized(); 477 information->showMaximized();
464} 478}
465 479
466/** 480/**
467 * Update this interface. If no QListViewItem exists create one. 481 * Update this interface. If no QListViewItem exists create one.
468 * @param Interface* pointer to the interface that needs to be updated. 482 * @param Interface* pointer to the interface that needs to be updated.
469 */ 483 */
470void MainWindowImp::updateInterface(Interface *i){ 484void MainWindowImp::updateInterface(Interface *i){
@@ -634,17 +648,16 @@ void MainWindowImp::makeChannel()
634 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 648 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
635 this, SLOT(receive(const QCString&, const QByteArray&)) ); 649 this, SLOT(receive(const QCString&, const QByteArray&)) );
636} 650}
637 651
638void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) 652void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
639{ 653{
640 bool found = false; 654 bool found = false;
641 qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); 655 qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
642
643 if (msg == "raise") { 656 if (msg == "raise") {
644 raise(); 657 raise();
645 return; 658 return;
646 } 659 }
647 660
648 QString dest = msg.left(msg.find("(")); 661 QString dest = msg.left(msg.find("("));
649 QCString param = msg.right(msg.length() - msg.find("(") - 1); 662 QCString param = msg.right(msg.length() - msg.find("(") - 1);
650 param = param.left( param.length() - 1 ); 663 param = param.left( param.length() - 1 );