6 files changed, 26 insertions, 180 deletions
diff --git a/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp index cf3dba1..1fa5d38 100644 --- a/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp +++ b/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp @@ -1,76 +1,76 @@ #include "interfaceinformationimp.h" #include "interfaceadvanced.h" #include <qpushbutton.h> #include <qlabel.h> #include <qgroupbox.h> #include <qmessagebox.h> /** * Constructor for the InterfaceInformationImp class. This class pretty much * just display's information about the interface that is passed to it. */ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); updateInterface(interface); connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); } /** * Update the interface information and buttons. * @param Intarface *i the interface to update (should be the one we already * know about). */ -void InterfaceInformationImp::updateInterface(Interface *i){ +void InterfaceInformationImp::updateInterface(Interface *){ if(interface->getStatus()){ startButton->setEnabled(false); stopButton->setEnabled(true); restartButton->setEnabled(true); } else{ startButton->setEnabled(true); stopButton->setEnabled(false); restartButton->setEnabled(false); } macAddressLabel->setText(interface->getMacAddress()); ipAddressLabel->setText(interface->getIp()); subnetMaskLabel->setText(interface->getSubnetMask()); broadcastLabel->setText(interface->getBroadcast()); } /** * Create the advanced widget. Fill it with the current interface's information. * Display it. */ void InterfaceInformationImp::advanced(){ InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); a->interfaceName->setText(interface->getInterfaceName()); a->macAddressLabel->setText(interface->getMacAddress()); a->ipAddressLabel->setText(interface->getIp()); a->subnetMaskLabel->setText(interface->getSubnetMask()); a->broadcastLabel->setText(interface->getBroadcast()); a->dhcpServerLabel->setText(interface->getDhcpServerIp()); a->leaseObtainedLabel->setText(interface->getLeaseObtained()); a->leaseExpiresLabel->setText(interface->getLeaseExpires()); a->dhcpInformation->setEnabled(interface->isDhcp()); a->showMaximized(); a->show(); } /** * Messages from the interface if start/stop went as planned. * Purly for user feedback. * @param message the message to display. */ void InterfaceInformationImp::showMessage(const QString &message){ QMessageBox::information(this, "Message", message, QMessageBox::Ok); } // infoimp.cpp diff --git a/noncore/net/networksetup/interfaces/interfacesetup.ui b/noncore/net/networksetup/interfaces/interfacesetup.ui index df55d25..2b45d49 100644 --- a/noncore/net/networksetup/interfaces/interfacesetup.ui +++ b/noncore/net/networksetup/interfaces/interfacesetup.ui @@ -1,174 +1,119 @@ <!DOCTYPE UI><UI> <class>InterfaceSetup</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>InterfaceSetup</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>290</width> + <width>286</width> <height>280</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Interface Configuration</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>autoStart</cstring> </property> <property stdset="1"> <name>text</name> <string>Automatically bring up</string> </property> </widget> <widget> - <class>QLayoutWidget</class> + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>Layout9</cstring> + <cstring>dhcpCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>DHCP</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpCheckBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>DHCP</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseHoursLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Requested Lease</string> - </property> - </widget> - <widget> - <class>QSpinBox</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseTime</cstring> - </property> - <property stdset="1"> - <name>suffix</name> - <string> hours</string> - </property> - <property stdset="1"> - <name>maxValue</name> - <number>87600</number> - </property> - <property stdset="1"> - <name>minValue</name> - <number>1</number> - </property> - <property stdset="1"> - <name>lineStep</name> - <number>24</number> - </property> - <property stdset="1"> - <name>value</name> - <number>168</number> - </property> - </widget> - </hbox> </widget> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>staticGroupBox</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>frameShape</name> <enum>Box</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>title</name> <string>Static Ip Configuration</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel5</cstring> </property> <property stdset="1"> <name>text</name> <string>Subnet Mask</string> </property> </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>gatewayEdit</cstring> </property> </widget> <widget row="1" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>subnetMaskEdit</cstring> </property> </widget> <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>ipAddressEdit</cstring> </property> </widget> @@ -220,91 +165,78 @@ <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>firstDNSLineEdit</cstring> </property> </widget> <widget row="4" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>secondDNSLineEdit</cstring> </property> </widget> </grid> </widget> <spacer> <property> <name>name</name> <cstring>Spacer9</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> <customwidgets> <customwidget> <class>QWidget</class> <header location="local">qwidget.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>7</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> <connections> <connection> <sender>dhcpCheckBox</sender> <signal>toggled(bool)</signal> - <receiver>leaseHoursLabel</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>dhcpCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>leaseTime</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>dhcpCheckBox</sender> - <signal>toggled(bool)</signal> <receiver>staticGroupBox</receiver> <slot>setDisabled(bool)</slot> </connection> </connections> <tabstops> <tabstop>autoStart</tabstop> <tabstop>dhcpCheckBox</tabstop> - <tabstop>leaseTime</tabstop> <tabstop>ipAddressEdit</tabstop> <tabstop>subnetMaskEdit</tabstop> <tabstop>gatewayEdit</tabstop> <tabstop>firstDNSLineEdit</tabstop> <tabstop>secondDNSLineEdit</tabstop> </tabstops> </UI> diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index 4818e37..56bbe93 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp @@ -1,145 +1,136 @@ #include "interfacesetupimp.h" #include "interface.h" #include <qcheckbox.h> #include <qlineedit.h> #include <qspinbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qmessagebox.h> #define DNSSCRIPT "changedns" /** * Constuctor. Set up the connection. A profile must be set. */ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ } /** * Save the current settings, then write out the interfaces file and close. */ 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.", QMessageBox::Ok); return false; } interfaces.removeAllInterfaceOptions(); // DHCP - if(dhcpCheckBox->isChecked()){ + 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()); return true; } /** * The Profile has changed. * @param QString profile the new profile. */ void InterfaceSetupImp::setProfile(const QString &profile){ /* bool error = false; if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } */ QString newInterfaceName = interface->getInterfaceName(); if(profile.length() > 0) newInterfaceName += "_" + profile; // See if we have to make a interface. if(!interfaces.setInterface(newInterfaceName)){ // Add making for this new interface if need too if(profile != ""){ interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); if(!interfaces.setMapping(interface->getInterfaceName())){ interfaces.addMapping(interface->getInterfaceName()); if(!interfaces.setMapping(interface->getInterfaceName())){ qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); return; } } interfaces.setMap("map", newInterfaceName); interfaces.setScript("getprofile.sh"); } else{ interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); if(!interfaces.setInterface(newInterfaceName)){ qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); return; } } } // We must have a valid interface to get this far so read some settings. // DHCP bool error = false; if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); else dhcpCheckBox->setChecked(false); - leaseTime->setValue(interfaces.getInterfaceOption("leasehours", error).toInt()); - if(error) - leaseTime->setValue(interfaces.getInterfaceOption("leasetime", error).toInt()/60/60); - if(error) - leaseTime->setValue(24); // IP Information autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); if(dns.contains(" ")){ firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); } ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); - } // interfacesetup.cpp diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp index cf3dba1..1fa5d38 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp @@ -1,76 +1,76 @@ #include "interfaceinformationimp.h" #include "interfaceadvanced.h" #include <qpushbutton.h> #include <qlabel.h> #include <qgroupbox.h> #include <qmessagebox.h> /** * Constructor for the InterfaceInformationImp class. This class pretty much * just display's information about the interface that is passed to it. */ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); updateInterface(interface); connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); } /** * Update the interface information and buttons. * @param Intarface *i the interface to update (should be the one we already * know about). */ -void InterfaceInformationImp::updateInterface(Interface *i){ +void InterfaceInformationImp::updateInterface(Interface *){ if(interface->getStatus()){ startButton->setEnabled(false); stopButton->setEnabled(true); restartButton->setEnabled(true); } else{ startButton->setEnabled(true); stopButton->setEnabled(false); restartButton->setEnabled(false); } macAddressLabel->setText(interface->getMacAddress()); ipAddressLabel->setText(interface->getIp()); subnetMaskLabel->setText(interface->getSubnetMask()); broadcastLabel->setText(interface->getBroadcast()); } /** * Create the advanced widget. Fill it with the current interface's information. * Display it. */ void InterfaceInformationImp::advanced(){ InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced"); a->interfaceName->setText(interface->getInterfaceName()); a->macAddressLabel->setText(interface->getMacAddress()); a->ipAddressLabel->setText(interface->getIp()); a->subnetMaskLabel->setText(interface->getSubnetMask()); a->broadcastLabel->setText(interface->getBroadcast()); a->dhcpServerLabel->setText(interface->getDhcpServerIp()); a->leaseObtainedLabel->setText(interface->getLeaseObtained()); a->leaseExpiresLabel->setText(interface->getLeaseExpires()); a->dhcpInformation->setEnabled(interface->isDhcp()); a->showMaximized(); a->show(); } /** * Messages from the interface if start/stop went as planned. * Purly for user feedback. * @param message the message to display. */ void InterfaceInformationImp::showMessage(const QString &message){ QMessageBox::information(this, "Message", message, QMessageBox::Ok); } // infoimp.cpp diff --git a/noncore/settings/networksettings/interfaces/interfacesetup.ui b/noncore/settings/networksettings/interfaces/interfacesetup.ui index df55d25..2b45d49 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetup.ui +++ b/noncore/settings/networksettings/interfaces/interfacesetup.ui @@ -1,174 +1,119 @@ <!DOCTYPE UI><UI> <class>InterfaceSetup</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>InterfaceSetup</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>290</width> + <width>286</width> <height>280</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Interface Configuration</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>autoStart</cstring> </property> <property stdset="1"> <name>text</name> <string>Automatically bring up</string> </property> </widget> <widget> - <class>QLayoutWidget</class> + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>Layout9</cstring> + <cstring>dhcpCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>DHCP</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpCheckBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>DHCP</string> - </property> - <property stdset="1"> - <name>checked</name> - <bool>true</bool> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseHoursLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Requested Lease</string> - </property> - </widget> - <widget> - <class>QSpinBox</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseTime</cstring> - </property> - <property stdset="1"> - <name>suffix</name> - <string> hours</string> - </property> - <property stdset="1"> - <name>maxValue</name> - <number>87600</number> - </property> - <property stdset="1"> - <name>minValue</name> - <number>1</number> - </property> - <property stdset="1"> - <name>lineStep</name> - <number>24</number> - </property> - <property stdset="1"> - <name>value</name> - <number>168</number> - </property> - </widget> - </hbox> </widget> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>staticGroupBox</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>frameShape</name> <enum>Box</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>Sunken</enum> </property> <property stdset="1"> <name>title</name> <string>Static Ip Configuration</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel5</cstring> </property> <property stdset="1"> <name>text</name> <string>Subnet Mask</string> </property> </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>gatewayEdit</cstring> </property> </widget> <widget row="1" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>subnetMaskEdit</cstring> </property> </widget> <widget row="0" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>ipAddressEdit</cstring> </property> </widget> @@ -220,91 +165,78 @@ <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>firstDNSLineEdit</cstring> </property> </widget> <widget row="4" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>secondDNSLineEdit</cstring> </property> </widget> </grid> </widget> <spacer> <property> <name>name</name> <cstring>Spacer9</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> <customwidgets> <customwidget> <class>QWidget</class> <header location="local">qwidget.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>7</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> <connections> <connection> <sender>dhcpCheckBox</sender> <signal>toggled(bool)</signal> - <receiver>leaseHoursLabel</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>dhcpCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>leaseTime</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>dhcpCheckBox</sender> - <signal>toggled(bool)</signal> <receiver>staticGroupBox</receiver> <slot>setDisabled(bool)</slot> </connection> </connections> <tabstops> <tabstop>autoStart</tabstop> <tabstop>dhcpCheckBox</tabstop> - <tabstop>leaseTime</tabstop> <tabstop>ipAddressEdit</tabstop> <tabstop>subnetMaskEdit</tabstop> <tabstop>gatewayEdit</tabstop> <tabstop>firstDNSLineEdit</tabstop> <tabstop>secondDNSLineEdit</tabstop> </tabstops> </UI> diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 4818e37..56bbe93 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp @@ -1,145 +1,136 @@ #include "interfacesetupimp.h" #include "interface.h" #include <qcheckbox.h> #include <qlineedit.h> #include <qspinbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qmessagebox.h> #define DNSSCRIPT "changedns" /** * Constuctor. Set up the connection. A profile must be set. */ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i){ } /** * Save the current settings, then write out the interfaces file and close. */ 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.", QMessageBox::Ok); return false; } interfaces.removeAllInterfaceOptions(); // DHCP - if(dhcpCheckBox->isChecked()){ + 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()); return true; } /** * The Profile has changed. * @param QString profile the new profile. */ void InterfaceSetupImp::setProfile(const QString &profile){ /* bool error = false; if(interfaces.getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } */ QString newInterfaceName = interface->getInterfaceName(); if(profile.length() > 0) newInterfaceName += "_" + profile; // See if we have to make a interface. if(!interfaces.setInterface(newInterfaceName)){ // Add making for this new interface if need too if(profile != ""){ interfaces.copyInterface(interface->getInterfaceName(), newInterfaceName); if(!interfaces.setMapping(interface->getInterfaceName())){ interfaces.addMapping(interface->getInterfaceName()); if(!interfaces.setMapping(interface->getInterfaceName())){ qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); return; } } interfaces.setMap("map", newInterfaceName); interfaces.setScript("getprofile.sh"); } else{ interfaces.addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); if(!interfaces.setInterface(newInterfaceName)){ qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); return; } } } // We must have a valid interface to get this far so read some settings. // DHCP bool error = false; if(interfaces.getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) dhcpCheckBox->setChecked(true); else dhcpCheckBox->setChecked(false); - leaseTime->setValue(interfaces.getInterfaceOption("leasehours", error).toInt()); - if(error) - leaseTime->setValue(interfaces.getInterfaceOption("leasetime", error).toInt()/60/60); - if(error) - leaseTime->setValue(24); // IP Information autoStart->setChecked(interfaces.isAuto(interface->getInterfaceName())); QString dns = interfaces.getInterfaceOption("up "DNSSCRIPT" -a", error); if(dns.contains(" ")){ firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); } ipAddressEdit->setText(interfaces.getInterfaceOption("address", error)); subnetMaskEdit->setText(interfaces.getInterfaceOption("netmask", error)); gatewayEdit->setText(interfaces.getInterfaceOption("gateway", error)); - } // interfacesetup.cpp |