summaryrefslogtreecommitdiff
path: root/noncore/net
Side-by-side diff
Diffstat (limited to 'noncore/net') (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
3 files changed, 15 insertions, 14 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 @@
CLEAN UP
Fix Profiles
-Write dns script
-
WLAN needs to be re-written to not use Config
Write a class that parses /proc and not ifconfig
-udchcp needs to output the dhcp information
+
+udchcp needs to output the dhcp information so interfaces can read it
+
+interfacesetupimp really doesn't need a interface* pointer
Possible other modules to write: ppp, ipsec, bluetooth, ipchains
PPP module needs to scan pppd.tdb to see what is currently active
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
bool InterfaceSetupImp::saveChanges(){
if(!saveSettings())
return false;
interfaces->write();
return true;
}
/**
* Save the settings for the current Interface.
* @return bool true if successfull, false otherwise
*/
bool InterfaceSetupImp::saveSettings(){
// eh can't really do anything about it other then return. :-D
if(!interfaces->isInterfaceSet())
return true;
bool error = false;
// Loopback case
if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){
interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked());
return true;
}
if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){
- QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", "Ok");
+ QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok);
return false;
}
interfaces->removeAllInterfaceOptions();
// DHCP
if(dhcpCheckBox->isChecked()){
interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP);
interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value()));
interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60));
}
else{
interfaces->setInterfaceMethod("static");
interfaces->setInterfaceOption("address", ipAddressEdit->text());
interfaces->setInterfaceOption("netmask", subnetMaskEdit->text());
interfaces->setInterfaceOption("gateway", gatewayEdit->text());
if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){
QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text();
interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns);
interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns);
}
}
// IP Information
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)
}
// Store for deletion later
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0){
- QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
+ QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
addNewConnection.showMaximized();
if(QDialog::Accepted == addNewConnection.exec()){
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
return;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()){
Interface *i = (it.key())->addNewInterface(item->text(0));
if(i){
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
}
}
}
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
void MainWindowImp::removeClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item) {
- QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok");
+ QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner() == NULL){
- QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
+ QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
}
else{
if(!i->getModuleOwner()->remove(i))
- QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
+ QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
else{
- QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
+ QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
// TODO memory managment....
// who deletes the interface?
}
}
}
/**
* Pull up the configure about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
if(moduleConfigure != NULL){
moduleConfigure->showMaximized();
moduleConfigure->show();
@@ -423,112 +423,112 @@ void MainWindowImp::updateInterface(Interface *i){
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
item->setPixmap(1, (Resource::loadPixmap(typeName)));
item->setText(2, i->getHardwareName());
item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
void MainWindowImp::newProfileChanged(const QString& newText){
if(newText.length() > 0)
newProfileButton->setEnabled(true);
else
newProfileButton->setEnabled(false);
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
QString newProfileName = newProfile->text();
if(profiles.grep(newProfileName).count() > 0){
- QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
+ QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
- QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
+ QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
return;
}
QString profileToRemove = profilesList->currentText();
if(profileToRemove == "All"){
- QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
+ QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
return;
}
// Can't remove the curent profile
if(profileToRemove == currentProfileLabel->text()){
- QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
+ QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
return;
}
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
// Remove any interface settings and mappings.
Interfaces interfaces;
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it ){
QString interfaceName = it.key()->getInterfaceName();
qDebug(interfaceName.latin1());
if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
interfaces.removeInterface();
if(interfaces.setMapping(interfaceName)){
if(profilesList->count() == 1)
interfaces.removeMapping();
else{
interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
}
}
interfaces.write();
break;
}
}
}
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(){
if(profilesList->currentItem() == -1){
- QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
+ QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
return;
}
QString newProfile = profilesList->text(profilesList->currentItem());
if(newProfile != currentProfileLabel->text()){
currentProfileLabel->setText(newProfile);
QFile::remove(scheme);
QFile file(scheme);
if ( file.open(IO_ReadWrite) ) {
QTextStream stream( &file );
stream << QString("SCHEME=%1").arg(newProfile);
file.close();
}
// restart all up devices?
if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it ){
if(it.key()->getStatus() == true)
it.key()->restart();
}
}
}
// TODO change the profile in the modules
}