summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO7
-rw-r--r--noncore/net/networksetup/interfaces/interfacesetupimp.cpp2
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp20
-rw-r--r--noncore/settings/networksettings/TODO7
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp2
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp20
6 files changed, 30 insertions, 28 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index ec6d2c6..d6bfee1 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,16 +1,17 @@
1CLEAN UP 1CLEAN UP
2 2
3Fix Profiles 3Fix Profiles
4 4
5Write dns script
6
7WLAN needs to be re-written to not use Config 5WLAN needs to be re-written to not use Config
8 6
9Write a class that parses /proc and not ifconfig 7Write a class that parses /proc and not ifconfig
10udchcp needs to output the dhcp information 8
9udchcp needs to output the dhcp information so interfaces can read it
10
11interfacesetupimp really doesn't need a interface* pointer
11 12
12Possible other modules to write: ppp, ipsec, bluetooth, ipchains 13Possible other modules to write: ppp, ipsec, bluetooth, ipchains
13 14
14PPP module needs to scan pppd.tdb to see what is currently active 15PPP module needs to scan pppd.tdb to see what is currently active
15 16
16 17
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp
index a19aaeb..3b1a4de 100644
--- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp
+++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp
@@ -39,49 +39,49 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac
39bool InterfaceSetupImp::saveChanges(){ 39bool InterfaceSetupImp::saveChanges(){
40 if(!saveSettings()) 40 if(!saveSettings())
41 return false; 41 return false;
42 interfaces->write(); 42 interfaces->write();
43 return true; 43 return true;
44} 44}
45 45
46/** 46/**
47 * Save the settings for the current Interface. 47 * Save the settings for the current Interface.
48 * @return bool true if successfull, false otherwise 48 * @return bool true if successfull, false otherwise
49 */ 49 */
50bool InterfaceSetupImp::saveSettings(){ 50bool InterfaceSetupImp::saveSettings(){
51 // eh can't really do anything about it other then return. :-D 51 // eh can't really do anything about it other then return. :-D
52 if(!interfaces->isInterfaceSet()) 52 if(!interfaces->isInterfaceSet())
53 return true; 53 return true;
54 54
55 bool error = false; 55 bool error = false;
56 // Loopback case 56 // Loopback case
57 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 57 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
58 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 58 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
59 return true; 59 return true;
60 } 60 }
61 61
62 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 62 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
63 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok"); 63 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
64 return false; 64 return false;
65 } 65 }
66 interfaces->removeAllInterfaceOptions(); 66 interfaces->removeAllInterfaceOptions();
67 67
68 // DHCP 68 // DHCP
69 if(dhcpCheckBox->isChecked()){ 69 if(dhcpCheckBox->isChecked()){
70 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 70 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
71 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); 71 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value()));
72 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); 72 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60));
73 } 73 }
74 else{ 74 else{
75 interfaces->setInterfaceMethod("static"); 75 interfaces->setInterfaceMethod("static");
76 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 76 interfaces->setInterfaceOption("address", ipAddressEdit->text());
77 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 77 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
78 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 78 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
79 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 79 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
80 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 80 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
81 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 81 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
82 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 82 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
83 } 83 }
84 } 84 }
85 85
86 // IP Information 86 // IP Information
87 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 87 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 6440bd4..3b0b7e8 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -148,91 +148,91 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
148 } 148 }
149 149
150 // Store for deletion later 150 // Store for deletion later
151 libraries.insert(object, lib); 151 libraries.insert(object, lib);
152 return object; 152 return object;
153} 153}
154 154
155/** 155/**
156 * The Add button was clicked. Bring up the add dialog and if OK is hit 156 * The Add button was clicked. Bring up the add dialog and if OK is hit
157 * load the plugin and append it to the list 157 * load the plugin and append it to the list
158 */ 158 */
159void MainWindowImp::addClicked(){ 159void MainWindowImp::addClicked(){
160 QMap<Module*, QLibrary*>::Iterator it; 160 QMap<Module*, QLibrary*>::Iterator it;
161 QMap<QString, QString> list; 161 QMap<QString, QString> list;
162 QMap<QString, Module*> newInterfaceOwners; 162 QMap<QString, Module*> newInterfaceOwners;
163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
165 for( it = libraries.begin(); it != libraries.end(); ++it ){ 165 for( it = libraries.begin(); it != libraries.end(); ++it ){
166 if(it.key()){ 166 if(it.key()){
167 (it.key())->possibleNewInterfaces(list); 167 (it.key())->possibleNewInterfaces(list);
168 } 168 }
169 } 169 }
170 // See if the list has anything that we can add. 170 // See if the list has anything that we can add.
171 if(list.count() == 0){ 171 if(list.count() == 0){
172 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 172 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
173 return; 173 return;
174 } 174 }
175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
176 addNewConnection.addConnections(list); 176 addNewConnection.addConnections(list);
177 addNewConnection.showMaximized(); 177 addNewConnection.showMaximized();
178 if(QDialog::Accepted == addNewConnection.exec()){ 178 if(QDialog::Accepted == addNewConnection.exec()){
179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
180 if(!item) 180 if(!item)
181 return; 181 return;
182 182
183 for( it = libraries.begin(); it != libraries.end(); ++it ){ 183 for( it = libraries.begin(); it != libraries.end(); ++it ){
184 if(it.key()){ 184 if(it.key()){
185 Interface *i = (it.key())->addNewInterface(item->text(0)); 185 Interface *i = (it.key())->addNewInterface(item->text(0));
186 if(i){ 186 if(i){
187 interfaceNames.insert(i->getInterfaceName(), i); 187 interfaceNames.insert(i->getInterfaceName(), i);
188 updateInterface(i); 188 updateInterface(i);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193} 193}
194 194
195/** 195/**
196 * Prompt the user to see if they really want to do this. 196 * Prompt the user to see if they really want to do this.
197 * If they do then remove from the list and unload. 197 * If they do then remove from the list and unload.
198 */ 198 */
199void MainWindowImp::removeClicked(){ 199void MainWindowImp::removeClicked(){
200 QListViewItem *item = connectionList->currentItem(); 200 QListViewItem *item = connectionList->currentItem();
201 if(!item) { 201 if(!item) {
202 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); 202 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
203 return; 203 return;
204 } 204 }
205 205
206 Interface *i = interfaceItems[item]; 206 Interface *i = interfaceItems[item];
207 if(i->getModuleOwner() == NULL){ 207 if(i->getModuleOwner() == NULL){
208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
209 } 209 }
210 else{ 210 else{
211 if(!i->getModuleOwner()->remove(i)) 211 if(!i->getModuleOwner()->remove(i))
212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 212 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
213 else{ 213 else{
214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 214 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::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. 224 * If the interface has a module owner then request its configure.
225 */ 225 */
226void MainWindowImp::configureClicked(){ 226void MainWindowImp::configureClicked(){
227 QListViewItem *item = connectionList->currentItem(); 227 QListViewItem *item = connectionList->currentItem();
228 if(!item){ 228 if(!item){
229 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 229 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
230 return; 230 return;
231 } 231 }
232 232
233 Interface *i = interfaceItems[item]; 233 Interface *i = interfaceItems[item];
234 if(i->getModuleOwner()){ 234 if(i->getModuleOwner()){
235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
236 if(moduleConfigure != NULL){ 236 if(moduleConfigure != NULL){
237 moduleConfigure->showMaximized(); 237 moduleConfigure->showMaximized();
238 moduleConfigure->show(); 238 moduleConfigure->show();
@@ -423,112 +423,112 @@ void MainWindowImp::updateInterface(Interface *i){
423 if(i->getModuleOwner() != NULL) 423 if(i->getModuleOwner() != NULL)
424 typeName = i->getModuleOwner()->getPixmapName(i); 424 typeName = i->getModuleOwner()->getPixmapName(i);
425 425
426 item->setPixmap(1, (Resource::loadPixmap(typeName))); 426 item->setPixmap(1, (Resource::loadPixmap(typeName)));
427 item->setText(2, i->getHardwareName()); 427 item->setText(2, i->getHardwareName());
428 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 428 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
429 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 429 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
430} 430}
431 431
432void MainWindowImp::newProfileChanged(const QString& newText){ 432void MainWindowImp::newProfileChanged(const QString& newText){
433 if(newText.length() > 0) 433 if(newText.length() > 0)
434 newProfileButton->setEnabled(true); 434 newProfileButton->setEnabled(true);
435 else 435 else
436 newProfileButton->setEnabled(false); 436 newProfileButton->setEnabled(false);
437} 437}
438 438
439/** 439/**
440 * Adds a new profile to the list of profiles. 440 * Adds a new profile to the list of profiles.
441 * Don't add profiles that already exists. 441 * Don't add profiles that already exists.
442 * Appends to the list and QStringList 442 * Appends to the list and QStringList
443 */ 443 */
444void MainWindowImp::addProfile(){ 444void MainWindowImp::addProfile(){
445 QString newProfileName = newProfile->text(); 445 QString newProfileName = newProfile->text();
446 if(profiles.grep(newProfileName).count() > 0){ 446 if(profiles.grep(newProfileName).count() > 0){
447 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 447 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
448 return; 448 return;
449 } 449 }
450 profiles.append(newProfileName); 450 profiles.append(newProfileName);
451 profilesList->insertItem(newProfileName); 451 profilesList->insertItem(newProfileName);
452} 452}
453 453
454/** 454/**
455 * Removes the currently selected profile in the combo. 455 * Removes the currently selected profile in the combo.
456 * Doesn't delete if there are less then 2 profiles. 456 * Doesn't delete if there are less then 2 profiles.
457 */ 457 */
458void MainWindowImp::removeProfile(){ 458void MainWindowImp::removeProfile(){
459 if(profilesList->count() <= 1){ 459 if(profilesList->count() <= 1){
460 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); 460 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
461 return; 461 return;
462 } 462 }
463 QString profileToRemove = profilesList->currentText(); 463 QString profileToRemove = profilesList->currentText();
464 if(profileToRemove == "All"){ 464 if(profileToRemove == "All"){
465 QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); 465 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
466 return; 466 return;
467 } 467 }
468 // Can't remove the curent profile 468 // Can't remove the curent profile
469 if(profileToRemove == currentProfileLabel->text()){ 469 if(profileToRemove == currentProfileLabel->text()){
470 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); 470 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
471 return; 471 return;
472 472
473 } 473 }
474 474
475 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 475 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
476 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 476 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
477 profilesList->clear(); 477 profilesList->clear();
478 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 478 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
479 profilesList->insertItem((*it)); 479 profilesList->insertItem((*it));
480 480
481 // Remove any interface settings and mappings. 481 // Remove any interface settings and mappings.
482 Interfaces interfaces; 482 Interfaces interfaces;
483 // Go through them one by one 483 // Go through them one by one
484 QMap<Interface*, QListViewItem*>::Iterator it; 484 QMap<Interface*, QListViewItem*>::Iterator it;
485 for( it = items.begin(); it != items.end(); ++it ){ 485 for( it = items.begin(); it != items.end(); ++it ){
486 QString interfaceName = it.key()->getInterfaceName(); 486 QString interfaceName = it.key()->getInterfaceName();
487 qDebug(interfaceName.latin1()); 487 qDebug(interfaceName.latin1());
488 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 488 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
489 interfaces.removeInterface(); 489 interfaces.removeInterface();
490 if(interfaces.setMapping(interfaceName)){ 490 if(interfaces.setMapping(interfaceName)){
491 if(profilesList->count() == 1) 491 if(profilesList->count() == 1)
492 interfaces.removeMapping(); 492 interfaces.removeMapping();
493 else{ 493 else{
494 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 494 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
495 } 495 }
496 } 496 }
497 interfaces.write(); 497 interfaces.write();
498 break; 498 break;
499 } 499 }
500 } 500 }
501 } 501 }
502} 502}
503 503
504/** 504/**
505 * A new profile has been selected, change. 505 * A new profile has been selected, change.
506 * @param newProfile the new profile. 506 * @param newProfile the new profile.
507 */ 507 */
508void MainWindowImp::changeProfile(){ 508void MainWindowImp::changeProfile(){
509 if(profilesList->currentItem() == -1){ 509 if(profilesList->currentItem() == -1){
510 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); 510 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
511 return; 511 return;
512 } 512 }
513 QString newProfile = profilesList->text(profilesList->currentItem()); 513 QString newProfile = profilesList->text(profilesList->currentItem());
514 if(newProfile != currentProfileLabel->text()){ 514 if(newProfile != currentProfileLabel->text()){
515 currentProfileLabel->setText(newProfile); 515 currentProfileLabel->setText(newProfile);
516 QFile::remove(scheme); 516 QFile::remove(scheme);
517 QFile file(scheme); 517 QFile file(scheme);
518 if ( file.open(IO_ReadWrite) ) { 518 if ( file.open(IO_ReadWrite) ) {
519 QTextStream stream( &file ); 519 QTextStream stream( &file );
520 stream << QString("SCHEME=%1").arg(newProfile); 520 stream << QString("SCHEME=%1").arg(newProfile);
521 file.close(); 521 file.close();
522 } 522 }
523 // restart all up devices? 523 // restart all up devices?
524 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 524 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
525 // Go through them one by one 525 // Go through them one by one
526 QMap<Interface*, QListViewItem*>::Iterator it; 526 QMap<Interface*, QListViewItem*>::Iterator it;
527 for( it = items.begin(); it != items.end(); ++it ){ 527 for( it = items.begin(); it != items.end(); ++it ){
528 if(it.key()->getStatus() == true) 528 if(it.key()->getStatus() == true)
529 it.key()->restart(); 529 it.key()->restart();
530 } 530 }
531 } 531 }
532 } 532 }
533 // TODO change the profile in the modules 533 // TODO change the profile in the modules
534} 534}
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index ec6d2c6..d6bfee1 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,16 +1,17 @@
1CLEAN UP 1CLEAN UP
2 2
3Fix Profiles 3Fix Profiles
4 4
5Write dns script
6
7WLAN needs to be re-written to not use Config 5WLAN needs to be re-written to not use Config
8 6
9Write a class that parses /proc and not ifconfig 7Write a class that parses /proc and not ifconfig
10udchcp needs to output the dhcp information 8
9udchcp needs to output the dhcp information so interfaces can read it
10
11interfacesetupimp really doesn't need a interface* pointer
11 12
12Possible other modules to write: ppp, ipsec, bluetooth, ipchains 13Possible other modules to write: ppp, ipsec, bluetooth, ipchains
13 14
14PPP module needs to scan pppd.tdb to see what is currently active 15PPP module needs to scan pppd.tdb to see what is currently active
15 16
16 17
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index a19aaeb..3b1a4de 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -39,49 +39,49 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac
39bool InterfaceSetupImp::saveChanges(){ 39bool InterfaceSetupImp::saveChanges(){
40 if(!saveSettings()) 40 if(!saveSettings())
41 return false; 41 return false;
42 interfaces->write(); 42 interfaces->write();
43 return true; 43 return true;
44} 44}
45 45
46/** 46/**
47 * Save the settings for the current Interface. 47 * Save the settings for the current Interface.
48 * @return bool true if successfull, false otherwise 48 * @return bool true if successfull, false otherwise
49 */ 49 */
50bool InterfaceSetupImp::saveSettings(){ 50bool InterfaceSetupImp::saveSettings(){
51 // eh can't really do anything about it other then return. :-D 51 // eh can't really do anything about it other then return. :-D
52 if(!interfaces->isInterfaceSet()) 52 if(!interfaces->isInterfaceSet())
53 return true; 53 return true;
54 54
55 bool error = false; 55 bool error = false;
56 // Loopback case 56 // Loopback case
57 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ 57 if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
58 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 58 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
59 return true; 59 return true;
60 } 60 }
61 61
62 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ 62 if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
63 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok"); 63 QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
64 return false; 64 return false;
65 } 65 }
66 interfaces->removeAllInterfaceOptions(); 66 interfaces->removeAllInterfaceOptions();
67 67
68 // DHCP 68 // DHCP
69 if(dhcpCheckBox->isChecked()){ 69 if(dhcpCheckBox->isChecked()){
70 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); 70 interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
71 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); 71 interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value()));
72 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); 72 interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60));
73 } 73 }
74 else{ 74 else{
75 interfaces->setInterfaceMethod("static"); 75 interfaces->setInterfaceMethod("static");
76 interfaces->setInterfaceOption("address", ipAddressEdit->text()); 76 interfaces->setInterfaceOption("address", ipAddressEdit->text());
77 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); 77 interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
78 interfaces->setInterfaceOption("gateway", gatewayEdit->text()); 78 interfaces->setInterfaceOption("gateway", gatewayEdit->text());
79 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ 79 if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
80 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); 80 QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
81 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); 81 interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
82 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); 82 interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
83 } 83 }
84 } 84 }
85 85
86 // IP Information 86 // IP Information
87 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); 87 interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 6440bd4..3b0b7e8 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -148,91 +148,91 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
148 } 148 }
149 149
150 // Store for deletion later 150 // Store for deletion later
151 libraries.insert(object, lib); 151 libraries.insert(object, lib);
152 return object; 152 return object;
153} 153}
154 154
155/** 155/**
156 * The Add button was clicked. Bring up the add dialog and if OK is hit 156 * The Add button was clicked. Bring up the add dialog and if OK is hit
157 * load the plugin and append it to the list 157 * load the plugin and append it to the list
158 */ 158 */
159void MainWindowImp::addClicked(){ 159void MainWindowImp::addClicked(){
160 QMap<Module*, QLibrary*>::Iterator it; 160 QMap<Module*, QLibrary*>::Iterator it;
161 QMap<QString, QString> list; 161 QMap<QString, QString> list;
162 QMap<QString, Module*> newInterfaceOwners; 162 QMap<QString, Module*> newInterfaceOwners;
163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 163 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 164 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
165 for( it = libraries.begin(); it != libraries.end(); ++it ){ 165 for( it = libraries.begin(); it != libraries.end(); ++it ){
166 if(it.key()){ 166 if(it.key()){
167 (it.key())->possibleNewInterfaces(list); 167 (it.key())->possibleNewInterfaces(list);
168 } 168 }
169 } 169 }
170 // See if the list has anything that we can add. 170 // See if the list has anything that we can add.
171 if(list.count() == 0){ 171 if(list.count() == 0){
172 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 172 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
173 return; 173 return;
174 } 174 }
175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 175 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
176 addNewConnection.addConnections(list); 176 addNewConnection.addConnections(list);
177 addNewConnection.showMaximized(); 177 addNewConnection.showMaximized();
178 if(QDialog::Accepted == addNewConnection.exec()){ 178 if(QDialog::Accepted == addNewConnection.exec()){
179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 179 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
180 if(!item) 180 if(!item)
181 return; 181 return;
182 182
183 for( it = libraries.begin(); it != libraries.end(); ++it ){ 183 for( it = libraries.begin(); it != libraries.end(); ++it ){
184 if(it.key()){ 184 if(it.key()){
185 Interface *i = (it.key())->addNewInterface(item->text(0)); 185 Interface *i = (it.key())->addNewInterface(item->text(0));
186 if(i){ 186 if(i){
187 interfaceNames.insert(i->getInterfaceName(), i); 187 interfaceNames.insert(i->getInterfaceName(), i);
188 updateInterface(i); 188 updateInterface(i);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
193} 193}
194 194
195/** 195/**
196 * Prompt the user to see if they really want to do this. 196 * Prompt the user to see if they really want to do this.
197 * If they do then remove from the list and unload. 197 * If they do then remove from the list and unload.
198 */ 198 */
199void MainWindowImp::removeClicked(){ 199void MainWindowImp::removeClicked(){
200 QListViewItem *item = connectionList->currentItem(); 200 QListViewItem *item = connectionList->currentItem();
201 if(!item) { 201 if(!item) {
202 QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); 202 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
203 return; 203 return;
204 } 204 }
205 205
206 Interface *i = interfaceItems[item]; 206 Interface *i = interfaceItems[item];
207 if(i->getModuleOwner() == NULL){ 207 if(i->getModuleOwner() == NULL){
208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 208 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
209 } 209 }
210 else{ 210 else{
211 if(!i->getModuleOwner()->remove(i)) 211 if(!i->getModuleOwner()->remove(i))
212 QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); 212 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
213 else{ 213 else{
214 QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); 214 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::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. 224 * If the interface has a module owner then request its configure.
225 */ 225 */
226void MainWindowImp::configureClicked(){ 226void MainWindowImp::configureClicked(){
227 QListViewItem *item = connectionList->currentItem(); 227 QListViewItem *item = connectionList->currentItem();
228 if(!item){ 228 if(!item){
229 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 229 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
230 return; 230 return;
231 } 231 }
232 232
233 Interface *i = interfaceItems[item]; 233 Interface *i = interfaceItems[item];
234 if(i->getModuleOwner()){ 234 if(i->getModuleOwner()){
235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 235 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
236 if(moduleConfigure != NULL){ 236 if(moduleConfigure != NULL){
237 moduleConfigure->showMaximized(); 237 moduleConfigure->showMaximized();
238 moduleConfigure->show(); 238 moduleConfigure->show();
@@ -423,112 +423,112 @@ void MainWindowImp::updateInterface(Interface *i){
423 if(i->getModuleOwner() != NULL) 423 if(i->getModuleOwner() != NULL)
424 typeName = i->getModuleOwner()->getPixmapName(i); 424 typeName = i->getModuleOwner()->getPixmapName(i);
425 425
426 item->setPixmap(1, (Resource::loadPixmap(typeName))); 426 item->setPixmap(1, (Resource::loadPixmap(typeName)));
427 item->setText(2, i->getHardwareName()); 427 item->setText(2, i->getHardwareName());
428 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 428 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
429 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 429 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
430} 430}
431 431
432void MainWindowImp::newProfileChanged(const QString& newText){ 432void MainWindowImp::newProfileChanged(const QString& newText){
433 if(newText.length() > 0) 433 if(newText.length() > 0)
434 newProfileButton->setEnabled(true); 434 newProfileButton->setEnabled(true);
435 else 435 else
436 newProfileButton->setEnabled(false); 436 newProfileButton->setEnabled(false);
437} 437}
438 438
439/** 439/**
440 * Adds a new profile to the list of profiles. 440 * Adds a new profile to the list of profiles.
441 * Don't add profiles that already exists. 441 * Don't add profiles that already exists.
442 * Appends to the list and QStringList 442 * Appends to the list and QStringList
443 */ 443 */
444void MainWindowImp::addProfile(){ 444void MainWindowImp::addProfile(){
445 QString newProfileName = newProfile->text(); 445 QString newProfileName = newProfile->text();
446 if(profiles.grep(newProfileName).count() > 0){ 446 if(profiles.grep(newProfileName).count() > 0){
447 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); 447 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
448 return; 448 return;
449 } 449 }
450 profiles.append(newProfileName); 450 profiles.append(newProfileName);
451 profilesList->insertItem(newProfileName); 451 profilesList->insertItem(newProfileName);
452} 452}
453 453
454/** 454/**
455 * Removes the currently selected profile in the combo. 455 * Removes the currently selected profile in the combo.
456 * Doesn't delete if there are less then 2 profiles. 456 * Doesn't delete if there are less then 2 profiles.
457 */ 457 */
458void MainWindowImp::removeProfile(){ 458void MainWindowImp::removeProfile(){
459 if(profilesList->count() <= 1){ 459 if(profilesList->count() <= 1){
460 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); 460 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
461 return; 461 return;
462 } 462 }
463 QString profileToRemove = profilesList->currentText(); 463 QString profileToRemove = profilesList->currentText();
464 if(profileToRemove == "All"){ 464 if(profileToRemove == "All"){
465 QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); 465 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
466 return; 466 return;
467 } 467 }
468 // Can't remove the curent profile 468 // Can't remove the curent profile
469 if(profileToRemove == currentProfileLabel->text()){ 469 if(profileToRemove == currentProfileLabel->text()){
470 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); 470 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
471 return; 471 return;
472 472
473 } 473 }
474 474
475 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 475 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
476 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 476 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
477 profilesList->clear(); 477 profilesList->clear();
478 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 478 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
479 profilesList->insertItem((*it)); 479 profilesList->insertItem((*it));
480 480
481 // Remove any interface settings and mappings. 481 // Remove any interface settings and mappings.
482 Interfaces interfaces; 482 Interfaces interfaces;
483 // Go through them one by one 483 // Go through them one by one
484 QMap<Interface*, QListViewItem*>::Iterator it; 484 QMap<Interface*, QListViewItem*>::Iterator it;
485 for( it = items.begin(); it != items.end(); ++it ){ 485 for( it = items.begin(); it != items.end(); ++it ){
486 QString interfaceName = it.key()->getInterfaceName(); 486 QString interfaceName = it.key()->getInterfaceName();
487 qDebug(interfaceName.latin1()); 487 qDebug(interfaceName.latin1());
488 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 488 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
489 interfaces.removeInterface(); 489 interfaces.removeInterface();
490 if(interfaces.setMapping(interfaceName)){ 490 if(interfaces.setMapping(interfaceName)){
491 if(profilesList->count() == 1) 491 if(profilesList->count() == 1)
492 interfaces.removeMapping(); 492 interfaces.removeMapping();
493 else{ 493 else{
494 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 494 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
495 } 495 }
496 } 496 }
497 interfaces.write(); 497 interfaces.write();
498 break; 498 break;
499 } 499 }
500 } 500 }
501 } 501 }
502} 502}
503 503
504/** 504/**
505 * A new profile has been selected, change. 505 * A new profile has been selected, change.
506 * @param newProfile the new profile. 506 * @param newProfile the new profile.
507 */ 507 */
508void MainWindowImp::changeProfile(){ 508void MainWindowImp::changeProfile(){
509 if(profilesList->currentItem() == -1){ 509 if(profilesList->currentItem() == -1){
510 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); 510 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
511 return; 511 return;
512 } 512 }
513 QString newProfile = profilesList->text(profilesList->currentItem()); 513 QString newProfile = profilesList->text(profilesList->currentItem());
514 if(newProfile != currentProfileLabel->text()){ 514 if(newProfile != currentProfileLabel->text()){
515 currentProfileLabel->setText(newProfile); 515 currentProfileLabel->setText(newProfile);
516 QFile::remove(scheme); 516 QFile::remove(scheme);
517 QFile file(scheme); 517 QFile file(scheme);
518 if ( file.open(IO_ReadWrite) ) { 518 if ( file.open(IO_ReadWrite) ) {
519 QTextStream stream( &file ); 519 QTextStream stream( &file );
520 stream << QString("SCHEME=%1").arg(newProfile); 520 stream << QString("SCHEME=%1").arg(newProfile);
521 file.close(); 521 file.close();
522 } 522 }
523 // restart all up devices? 523 // restart all up devices?
524 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 524 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
525 // Go through them one by one 525 // Go through them one by one
526 QMap<Interface*, QListViewItem*>::Iterator it; 526 QMap<Interface*, QListViewItem*>::Iterator it;
527 for( it = items.begin(); it != items.end(); ++it ){ 527 for( it = items.begin(); it != items.end(); ++it ){
528 if(it.key()->getStatus() == true) 528 if(it.key()->getStatus() == true)
529 it.key()->restart(); 529 it.key()->restart();
530 } 530 }
531 } 531 }
532 } 532 }
533 // TODO change the profile in the modules 533 // TODO change the profile in the modules
534} 534}