summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2003-04-09 19:35:25 (UTC)
committer benmeyer <benmeyer>2003-04-09 19:35:25 (UTC)
commit76fd85d1d8aaf1140feb59044add12e52f4e76f0 (patch) (unidiff)
treeacf35c4d40aeb6bbd7d01034df8353cda6ade091
parent6e2ee769c8e6cba600e235822d5003cfe31e55c5 (diff)
downloadopie-76fd85d1d8aaf1140feb59044add12e52f4e76f0.zip
opie-76fd85d1d8aaf1140feb59044add12e52f4e76f0.tar.gz
opie-76fd85d1d8aaf1140feb59044add12e52f4e76f0.tar.bz2
compile fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp7
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h4
2 files changed, 3 insertions, 8 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 581b7e3..da21c05 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,70 +1,69 @@
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#include "module.h" 6#include "module.h"
7 7
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 14
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16 16
17#ifdef QWS 17#ifdef QWS
18 #include <qpe/config.h> 18 #include <qpe/config.h>
19 #include <qpe/qlibrary.h> 19 #include <qpe/qlibrary.h>
20 #include <qpe/resource.h> 20 #include <qpe/resource.h>
21 #include <qpe/qpeapplication.h> 21 #include <qpe/qpeapplication.h>
22// #define QLibrary Library
23#else 22#else
24 #include <klibloader.h> 23 #include <klibloader.h>
25 #define QLibrary KLibrary 24 #define QLibrary KLibrary
26 #include <kconfig.h> 25 #include <kconfig.h>
27 #define Config KConfig 26 #define Config KConfig
28 #include <kapplication.h> 27 #include <kapplication.h>
29 #include <kstandarddirs.h> 28 #include <kstandarddirs.h>
30 #include <kiconloader.h> 29 #include <kiconloader.h>
31 #define showMaximized show 30 #define showMaximized show
32#endif 31#endif
33 32
34#if QT_VERSION < 300 33#if QT_VERSION < 300
35#include <qlist.h> 34#include <qlist.h>
36#else 35#else
37#include <qptrlist.h> 36#include <qptrlist.h>
38#endif 37#endif
39#include <qdir.h> 38#include <qdir.h>
40#include <qfile.h> 39#include <qfile.h>
41#include <qtextstream.h> 40#include <qtextstream.h>
42#include <qregexp.h> 41#include <qregexp.h>
43 42
44#include <net/if.h> 43#include <net/if.h>
45#include <sys/ioctl.h> 44#include <sys/ioctl.h>
46 45
47#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 46#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
48 47
49MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 48MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){
50 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 49 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
51 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 50 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
52 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 51 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
53 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 52 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
54 53
55 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 54 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
56 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 55 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
57 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 56 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
58 57
59 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 58 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
60 // Load connections. 59 // Load connections.
61 // /usr/local/kde/lib/libinterfaces.la 60 // /usr/local/kde/lib/libinterfaces.la
62#ifdef QWS 61#ifdef QWS
63 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); 62 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings");
64#else 63#else
65 loader = KLibLoader::self(); 64 loader = KLibLoader::self();
66 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 65 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
67#endif 66#endif
68 getAllInterfaces(); 67 getAllInterfaces();
69 68
70 Interfaces i; 69 Interfaces i;
@@ -337,133 +336,133 @@ void MainWindowImp::addClicked(){
337 336
338/** 337/**
339 * Prompt the user to see if they really want to do this. 338 * Prompt the user to see if they really want to do this.
340 * If they do then remove from the list and unload. 339 * If they do then remove from the list and unload.
341 */ 340 */
342void MainWindowImp::removeClicked(){ 341void MainWindowImp::removeClicked(){
343 QListViewItem *item = connectionList->currentItem(); 342 QListViewItem *item = connectionList->currentItem();
344 if(!item) { 343 if(!item) {
345 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 344 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
346 return; 345 return;
347 } 346 }
348 347
349 Interface *i = interfaceItems[item]; 348 Interface *i = interfaceItems[item];
350 if(i->getModuleOwner() == NULL){ 349 if(i->getModuleOwner() == NULL){
351 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 350 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
352 } 351 }
353 else{ 352 else{
354 if(!i->getModuleOwner()->remove(i)) 353 if(!i->getModuleOwner()->remove(i))
355 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); 354 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
356 else{ 355 else{
357 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 356 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
358 // TODO memory managment.... 357 // TODO memory managment....
359 // who deletes the interface? 358 // who deletes the interface?
360 } 359 }
361 } 360 }
362} 361}
363 362
364/** 363/**
365 * Pull up the configure about the currently selected interface. 364 * Pull up the configure about the currently selected interface.
366 * Report an error if no interface is selected. 365 * Report an error if no interface is selected.
367 * If the interface has a module owner then request its configure. 366 * If the interface has a module owner then request its configure.
368 */ 367 */
369void MainWindowImp::configureClicked(){ 368void MainWindowImp::configureClicked(){
370 QListViewItem *item = connectionList->currentItem(); 369 QListViewItem *item = connectionList->currentItem();
371 if(!item){ 370 if(!item){
372 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 371 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
373 return; 372 return;
374 } 373 }
375 374
376 Interface *i = interfaceItems[item]; 375 Interface *i = interfaceItems[item];
377 if(i->getModuleOwner()){ 376 if(i->getModuleOwner()){
378 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 377 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
379 if(moduleConfigure != NULL){ 378 if(moduleConfigure != NULL){
380 moduleConfigure->showMaximized(); 379 moduleConfigure->showMaximized();
381 return; 380 return;
382 } 381 }
383 } 382 }
384 383
385 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 384 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose );
386 QString currentProfileText = currentProfileLabel->text(); 385 QString currentProfileText = currentProfileLabel->text();
387 if(currentProfileText.upper() == "ALL"); 386 if(currentProfileText.upper() == "ALL");
388 currentProfileText = ""; 387 currentProfileText = "";
389 configure->setProfile(currentProfileText); 388 configure->setProfile(currentProfileText);
390 configure->showMaximized(); 389 configure->showMaximized();
391} 390}
392 391
393/** 392/**
394 * Pull up the information about the currently selected interface. 393 * Pull up the information about the currently selected interface.
395 * Report an error if no interface is selected. 394 * Report an error if no interface is selected.
396 * If the interface has a module owner then request its configure. 395 * If the interface has a module owner then request its configure.
397 */ 396 */
398void MainWindowImp::informationClicked(){ 397void MainWindowImp::informationClicked(){
399 QListViewItem *item = connectionList->currentItem(); 398 QListViewItem *item = connectionList->currentItem();
400 if(!item){ 399 if(!item){
401 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 400 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
402 return; 401 return;
403 } 402 }
404 403
405 Interface *i = interfaceItems[item]; 404 Interface *i = interfaceItems[item];
406 if(!i->isAttached()){ 405 if(!i->isAttached()){
407 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 406 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
408 return; 407 return;
409 } 408 }
410 409
411 if(i->getModuleOwner()){ 410 if(i->getModuleOwner()){
412 QWidget *moduleInformation = i->getModuleOwner()->information(i); 411 QWidget *moduleInformation = i->getModuleOwner()->information(i);
413 if(moduleInformation != NULL){ 412 if(moduleInformation != NULL){
414 moduleInformation->showMaximized(); 413 moduleInformation->showMaximized();
415#ifdef DEBUG 414#ifdef DEBUG
416 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 415 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
417#endif 416#endif
418 return; 417 return;
419 } 418 }
420 } 419 }
421 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 420 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WType_Dialog);
422 information->showMaximized(); 421 information->showMaximized();
423} 422}
424 423
425/** 424/**
426 * Update this interface. If no QListViewItem exists create one. 425 * Update this interface. If no QListViewItem exists create one.
427 * @param Interface* pointer to the interface that needs to be updated. 426 * @param Interface* pointer to the interface that needs to be updated.
428 */ 427 */
429void MainWindowImp::updateInterface(Interface *i){ 428void MainWindowImp::updateInterface(Interface *i){
430 if(!advancedUserMode){ 429 if(!advancedUserMode){
431 if(i->getInterfaceName() == "lo") 430 if(i->getInterfaceName() == "lo")
432 return; 431 return;
433 } 432 }
434 433
435 QListViewItem *item = NULL; 434 QListViewItem *item = NULL;
436 435
437 // Find the interface, making it if needed. 436 // Find the interface, making it if needed.
438 if(items.find(i) == items.end()){ 437 if(items.find(i) == items.end()){
439 item = new QListViewItem(connectionList, "", "", ""); 438 item = new QListViewItem(connectionList, "", "", "");
440 // See if you can't find a module owner for this interface 439 // See if you can't find a module owner for this interface
441 QMap<Module*, QLibrary*>::Iterator it; 440 QMap<Module*, QLibrary*>::Iterator it;
442 for( it = libraries.begin(); it != libraries.end(); ++it ){ 441 for( it = libraries.begin(); it != libraries.end(); ++it ){
443 if(it.key()->isOwner(i)) 442 if(it.key()->isOwner(i))
444 i->setModuleOwner(it.key()); 443 i->setModuleOwner(it.key());
445 } 444 }
446 items.insert(i, item); 445 items.insert(i, item);
447 interfaceItems.insert(item, i); 446 interfaceItems.insert(item, i);
448 } 447 }
449 else 448 else
450 item = items[i]; 449 item = items[i];
451 450
452 // Update the icons and information 451 // Update the icons and information
453#ifdef QWS 452#ifdef QWS
454 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 453 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
455#else 454#else
456 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); 455 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
457#endif 456#endif
458 457
459 QString typeName = "lan"; 458 QString typeName = "lan";
460 if(i->getHardwareName().contains("Local Loopback")) 459 if(i->getHardwareName().contains("Local Loopback"))
461 typeName = "lo"; 460 typeName = "lo";
462 if(i->getInterfaceName().contains("irda")) 461 if(i->getInterfaceName().contains("irda"))
463 typeName = "irda"; 462 typeName = "irda";
464 if(i->getInterfaceName().contains("wlan")) 463 if(i->getInterfaceName().contains("wlan"))
465 typeName = "wlan"; 464 typeName = "wlan";
466 if(i->getInterfaceName().contains("usb")) 465 if(i->getInterfaceName().contains("usb"))
467 typeName = "usb"; 466 typeName = "usb";
468 467
469 if(!i->isAttached()) 468 if(!i->isAttached())
@@ -541,50 +540,48 @@ void MainWindowImp::removeProfile(){
541 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 540 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
542 interfaces.removeInterface(); 541 interfaces.removeInterface();
543 if(interfaces.setMapping(interfaceName)){ 542 if(interfaces.setMapping(interfaceName)){
544 if(profilesList->count() == 1) 543 if(profilesList->count() == 1)
545 interfaces.removeMapping(); 544 interfaces.removeMapping();
546 else{ 545 else{
547 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 546 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
548 } 547 }
549 } 548 }
550 interfaces.write(); 549 interfaces.write();
551 break; 550 break;
552 } 551 }
553 } 552 }
554 } 553 }
555} 554}
556 555
557/** 556/**
558 * A new profile has been selected, change. 557 * A new profile has been selected, change.
559 * @param newProfile the new profile. 558 * @param newProfile the new profile.
560 */ 559 */
561void MainWindowImp::changeProfile(){ 560void MainWindowImp::changeProfile(){
562 if(profilesList->currentItem() == -1){ 561 if(profilesList->currentItem() == -1){
563 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 562 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
564 return; 563 return;
565 } 564 }
566 QString newProfile = profilesList->text(profilesList->currentItem()); 565 QString newProfile = profilesList->text(profilesList->currentItem());
567 if(newProfile != currentProfileLabel->text()){ 566 if(newProfile != currentProfileLabel->text()){
568 currentProfileLabel->setText(newProfile); 567 currentProfileLabel->setText(newProfile);
569 QFile::remove(scheme); 568 QFile::remove(scheme);
570 QFile file(scheme); 569 QFile file(scheme);
571 if ( file.open(IO_ReadWrite) ) { 570 if ( file.open(IO_ReadWrite) ) {
572 QTextStream stream( &file ); 571 QTextStream stream( &file );
573 stream << QString("SCHEME=%1").arg(newProfile); 572 stream << QString("SCHEME=%1").arg(newProfile);
574 file.close(); 573 file.close();
575 } 574 }
576 // restart all up devices? 575 // restart all up devices?
577 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 576 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
578 // Go through them one by one 577 // Go through them one by one
579 QMap<Interface*, QListViewItem*>::Iterator it; 578 QMap<Interface*, QListViewItem*>::Iterator it;
580 for( it = items.begin(); it != items.end(); ++it ){ 579 for( it = items.begin(); it != items.end(); ++it ){
581 if(it.key()->getStatus() == true) 580 if(it.key()->getStatus() == true)
582 it.key()->restart(); 581 it.key()->restart();
583 } 582 }
584 } 583 }
585 } 584 }
586 // TODO change the profile in the modules 585 // TODO change the profile in the modules
587} 586}
588 587
589// mainwindowimp.cpp
590
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 49f3eea..c045fe6 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -18,52 +18,50 @@ class KLibLoader;
18#endif 18#endif
19 19
20 20
21class MainWindowImp : public MainWindow { 21class MainWindowImp : public MainWindow {
22 Q_OBJECT 22 Q_OBJECT
23 23
24public: 24public:
25 MainWindowImp(QWidget *parent=0, const char *name=0); 25 MainWindowImp(QWidget *parent=0, const char *name=0);
26 ~MainWindowImp(); 26 ~MainWindowImp();
27 27
28private slots: 28private slots:
29 void getAllInterfaces(); 29 void getAllInterfaces();
30 30
31 void addClicked(); 31 void addClicked();
32 void removeClicked(); 32 void removeClicked();
33 void configureClicked(); 33 void configureClicked();
34 void informationClicked(); 34 void informationClicked();
35 35
36 void addProfile(); 36 void addProfile();
37 void removeProfile(); 37 void removeProfile();
38 void changeProfile(); 38 void changeProfile();
39 39
40 void updateInterface(Interface *i); 40 void updateInterface(Interface *i);
41 void newProfileChanged(const QString& newText); 41 void newProfileChanged(const QString& newText);
42 42
43private: 43private:
44 void loadModules(const QString &path); 44 void loadModules(const QString &path);
45 45
46 Module* loadPlugin(const QString &pluginFileName, 46 Module* loadPlugin(const QString &pluginFileName,
47 const QString &resolveString = "create_plugin"); 47 const QString &resolveString = "create_plugin");
48 48
49 // For our local list of names 49 // For our local list of names
50 QMap<QString, Interface*> interfaceNames; 50 QMap<QString, Interface*> interfaceNames;
51 51
52 QMap<Module*, QLibrary*> libraries; 52 QMap<Module*, QLibrary*> libraries;
53 QMap<Interface*, QListViewItem*> items; 53 QMap<Interface*, QListViewItem*> items;
54 QMap<QListViewItem*, Interface*> interfaceItems; 54 QMap<QListViewItem*, Interface*> interfaceItems;
55 55
56 QMap<KProcess*, QString> threads; 56 QMap<KProcess*, QString> threads;
57 QStringList profiles; 57 QStringList profiles;
58 58
59 bool advancedUserMode; 59 bool advancedUserMode;
60 QString scheme; 60 QString scheme;
61#ifndef QWS 61#ifndef QWS
62 KLibLoader *loader; 62 KLibLoader *loader;
63#endif 63#endif
64}; 64};
65 65
66#endif 66#endif // MAINWINOWIMP_H
67
68// mainwindowimp.h
69 67