-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index abf5663..a0b3113 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -41,97 +41,97 @@ | |||
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | 43 | ||
44 | #include <net/if.h> | 44 | #include <net/if.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #include <sys/socket.h> | 46 | #include <sys/socket.h> |
47 | 47 | ||
48 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 48 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
49 | #define _PROCNETDEV "/proc/net/dev" | 49 | #define _PROCNETDEV "/proc/net/dev" |
50 | 50 | ||
51 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 51 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ |
52 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 52 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
53 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 53 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
54 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 54 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
55 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 55 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
56 | 56 | ||
57 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 57 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
58 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 58 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
59 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 59 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
60 | 60 | ||
61 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 61 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
62 | 62 | ||
63 | //FIXME: disable profiles for the moment: | 63 | //FIXME: disable profiles for the moment: |
64 | tabWidget->setTabEnabled( tab, false ); | 64 | tabWidget->setTabEnabled( tab, false ); |
65 | 65 | ||
66 | // Load connections. | 66 | // Load connections. |
67 | // /usr/local/kde/lib/libinterfaces.la | 67 | // /usr/local/kde/lib/libinterfaces.la |
68 | #ifdef QWS | 68 | #ifdef QWS |
69 | loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); | 69 | loadModules(QPEApplication::qpeDir() + "/plugins/networksettings"); |
70 | #else | 70 | #else |
71 | loader = KLibLoader::self(); | 71 | loader = KLibLoader::self(); |
72 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 72 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
73 | #endif | 73 | #endif |
74 | getAllInterfaces(); | 74 | getAllInterfaces(); |
75 | 75 | ||
76 | Interfaces i; | 76 | Interfaces i; |
77 | QStringList list = i.getInterfaceList(); | 77 | QStringList list = i.getInterfaceList(); |
78 | QMap<QString, Interface*>::Iterator it; | 78 | QMap<QString, Interface*>::Iterator it; |
79 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 79 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
80 | bool found = false; | 80 | bool found = false; |
81 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 81 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
82 | if(it.key() == (*ni)) | 82 | if(it.key() == (*ni)) |
83 | found = true; | 83 | found = true; |
84 | } | 84 | } |
85 | if(!found){ | 85 | if(!found){ |
86 | if(!(*ni).contains("_")){ | 86 | if(!(*ni).contains("_")){ |
87 | Interface *i = new Interface(this, *ni, false); | 87 | Interface *i = new Interface(this, *ni, false); |
88 | i->setAttached(false); | 88 | i->setAttached(false); |
89 | i->setHardwareName("Disconnected"); | 89 | i->setHardwareName(tr("Disconnected")); |
90 | interfaceNames.insert(i->getInterfaceName(), i); | 90 | interfaceNames.insert(i->getInterfaceName(), i); |
91 | updateInterface(i); | 91 | updateInterface(i); |
92 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 92 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | //getInterfaceList(); | 97 | //getInterfaceList(); |
98 | connectionList->header()->hide(); | 98 | connectionList->header()->hide(); |
99 | 99 | ||
100 | Config cfg("NetworkSetup"); | 100 | Config cfg("NetworkSetup"); |
101 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 101 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
102 | for ( QStringList::Iterator it = profiles.begin(); | 102 | for ( QStringList::Iterator it = profiles.begin(); |
103 | it != profiles.end(); ++it) | 103 | it != profiles.end(); ++it) |
104 | profilesList->insertItem((*it)); | 104 | profilesList->insertItem((*it)); |
105 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 105 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
106 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 106 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
107 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 107 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
108 | 108 | ||
109 | QFile file(scheme); | 109 | QFile file(scheme); |
110 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 110 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
111 | QTextStream stream( &file ); // use a text stream | 111 | QTextStream stream( &file ); // use a text stream |
112 | while ( !stream.eof() ) { // until end of file... | 112 | while ( !stream.eof() ) { // until end of file... |
113 | QString line = stream.readLine(); // line of text excluding '\n' | 113 | QString line = stream.readLine(); // line of text excluding '\n' |
114 | if(line.contains("SCHEME")){ | 114 | if(line.contains("SCHEME")){ |
115 | line = line.mid(7, line.length()); | 115 | line = line.mid(7, line.length()); |
116 | currentProfileLabel->setText(line); | 116 | currentProfileLabel->setText(line); |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | file.close(); | 120 | file.close(); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Deconstructor. Save profiles. Delete loaded libraries. | 125 | * Deconstructor. Save profiles. Delete loaded libraries. |
126 | */ | 126 | */ |
127 | MainWindowImp::~MainWindowImp(){ | 127 | MainWindowImp::~MainWindowImp(){ |
128 | // Save profiles. | 128 | // Save profiles. |
129 | Config cfg("NetworkSetup"); | 129 | Config cfg("NetworkSetup"); |
130 | cfg.setGroup("General"); | 130 | cfg.setGroup("General"); |
131 | cfg.writeEntry("Profiles", profiles.join(" ")); | 131 | cfg.writeEntry("Profiles", profiles.join(" ")); |
132 | 132 | ||
133 | // Delete all interfaces that don't have owners. | 133 | // Delete all interfaces that don't have owners. |
134 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 134 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
135 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 135 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
136 | if(iIt.key()->getModuleOwner() == NULL) | 136 | if(iIt.key()->getModuleOwner() == NULL) |
137 | delete iIt.key(); | 137 | delete iIt.key(); |
@@ -343,114 +343,113 @@ void MainWindowImp::addClicked(){ | |||
343 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 343 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
344 | if(it.key()){ | 344 | if(it.key()){ |
345 | (it.key())->possibleNewInterfaces(list); | 345 | (it.key())->possibleNewInterfaces(list); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | // See if the list has anything that we can add. | 348 | // See if the list has anything that we can add. |
349 | if(list.count() == 0){ | 349 | if(list.count() == 0){ |
350 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 350 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 353 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
354 | addNewConnection.addConnections(list); | 354 | addNewConnection.addConnections(list); |
355 | addNewConnection.showMaximized(); | 355 | addNewConnection.showMaximized(); |
356 | if(QDialog::Accepted == addNewConnection.exec()){ | 356 | if(QDialog::Accepted == addNewConnection.exec()){ |
357 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 357 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
358 | if(!item) | 358 | if(!item) |
359 | return; | 359 | return; |
360 | 360 | ||
361 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 361 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
362 | if(it.key()){ | 362 | if(it.key()){ |
363 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 363 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
364 | if(i){ | 364 | if(i){ |
365 | qDebug("iface name %s",i->getInterfaceName().latin1()); | 365 | qDebug("iface name %s",i->getInterfaceName().latin1()); |
366 | interfaceNames.insert(i->getInterfaceName(), i); | 366 | interfaceNames.insert(i->getInterfaceName(), i); |
367 | updateInterface(i); | 367 | updateInterface(i); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | /** | 374 | /** |
375 | * Prompt the user to see if they really want to do this. | 375 | * Prompt the user to see if they really want to do this. |
376 | * If they do then remove from the list and unload. | 376 | * If they do then remove from the list and unload. |
377 | */ | 377 | */ |
378 | void MainWindowImp::removeClicked(){ | 378 | void MainWindowImp::removeClicked(){ |
379 | QListViewItem *item = connectionList->currentItem(); | 379 | QListViewItem *item = connectionList->currentItem(); |
380 | if(!item) { | 380 | if(!item) { |
381 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 381 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | 384 | ||
385 | Interface *i = interfaceItems[item]; | 385 | Interface *i = interfaceItems[item]; |
386 | if(i->getModuleOwner() == NULL){ | 386 | if(i->getModuleOwner() == NULL){ |
387 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 387 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
388 | } | 388 | } |
389 | else{ | 389 | else{ |
390 | if(!i->getModuleOwner()->remove(i)) | 390 | if(!i->getModuleOwner()->remove(i)) |
391 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); | 391 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
392 | else{ | 392 | else{ |
393 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 393 | delete item; |
394 | // TODO memory managment.... | 394 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
395 | // who deletes the interface? | ||
396 | } | 395 | } |
397 | } | 396 | } |
398 | } | 397 | } |
399 | 398 | ||
400 | /** | 399 | /** |
401 | * Pull up the configure about the currently selected interface. | 400 | * Pull up the configure about the currently selected interface. |
402 | * Report an error if no interface is selected. | 401 | * Report an error if no interface is selected. |
403 | * If the interface has a module owner then request its configure. | 402 | * If the interface has a module owner then request its configure. |
404 | */ | 403 | */ |
405 | void MainWindowImp::configureClicked(){ | 404 | void MainWindowImp::configureClicked(){ |
406 | QListViewItem *item = connectionList->currentItem(); | 405 | QListViewItem *item = connectionList->currentItem(); |
407 | if(!item){ | 406 | if(!item){ |
408 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 407 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
409 | return; | 408 | return; |
410 | } | 409 | } |
411 | 410 | ||
412 | QString currentProfileText = currentProfileLabel->text(); | 411 | QString currentProfileText = currentProfileLabel->text(); |
413 | if(currentProfileText.upper() == "ALL"); | 412 | if(currentProfileText.upper() == "ALL"); |
414 | currentProfileText = ""; | 413 | currentProfileText = ""; |
415 | 414 | ||
416 | Interface *i = interfaceItems[item]; | 415 | Interface *i = interfaceItems[item]; |
417 | 416 | ||
418 | if(i->getModuleOwner()){ | 417 | if(i->getModuleOwner()){ |
419 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 418 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
420 | if(moduleConfigure != NULL){ | 419 | if(moduleConfigure != NULL){ |
421 | i->getModuleOwner()->setProfile(currentProfileText); | 420 | i->getModuleOwner()->setProfile(currentProfileText); |
422 | moduleConfigure->showMaximized(); | 421 | moduleConfigure->showMaximized(); |
423 | return; | 422 | return; |
424 | } | 423 | } |
425 | } | 424 | } |
426 | 425 | ||
427 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); | 426 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); |
428 | configure->setProfile(currentProfileText); | 427 | configure->setProfile(currentProfileText); |
429 | configure->showMaximized(); | 428 | configure->showMaximized(); |
430 | } | 429 | } |
431 | 430 | ||
432 | /** | 431 | /** |
433 | * Pull up the information about the currently selected interface. | 432 | * Pull up the information about the currently selected interface. |
434 | * Report an error if no interface is selected. | 433 | * Report an error if no interface is selected. |
435 | * If the interface has a module owner then request its configure. | 434 | * If the interface has a module owner then request its configure. |
436 | */ | 435 | */ |
437 | void MainWindowImp::informationClicked(){ | 436 | void MainWindowImp::informationClicked(){ |
438 | QListViewItem *item = connectionList->currentItem(); | 437 | QListViewItem *item = connectionList->currentItem(); |
439 | if(!item){ | 438 | if(!item){ |
440 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 439 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
441 | return; | 440 | return; |
442 | } | 441 | } |
443 | 442 | ||
444 | Interface *i = interfaceItems[item]; | 443 | Interface *i = interfaceItems[item]; |
445 | // if(!i->isAttached()){ | 444 | // if(!i->isAttached()){ |
446 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 445 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
447 | // return; | 446 | // return; |
448 | // } | 447 | // } |
449 | 448 | ||
450 | if(i->getModuleOwner()){ | 449 | if(i->getModuleOwner()){ |
451 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 450 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
452 | if(moduleInformation != NULL){ | 451 | if(moduleInformation != NULL){ |
453 | moduleInformation->showMaximized(); | 452 | moduleInformation->showMaximized(); |
454 | #ifdef DEBUG | 453 | #ifdef DEBUG |
455 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 454 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
456 | #endif | 455 | #endif |