author | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:14:54 (UTC) |
commit | a7e015198a8c5ad3b6e144a9032b059086253e00 (patch) (side-by-side diff) | |
tree | b712b6f11310d88744fe393a92b3160b741a7efe /noncore/settings/networksettings/interfaces | |
parent | beba0e73306815337bf04dee39502233595e9739 (diff) | |
download | opie-a7e015198a8c5ad3b6e144a9032b059086253e00.zip opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.gz opie-a7e015198a8c5ad3b6e144a9032b059086253e00.tar.bz2 |
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/settings/networksettings/interfaces') (more/less context) (ignore whitespace changes)
8 files changed, 254 insertions, 185 deletions
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index cc45525..69b55d1 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp @@ -3,3 +3,3 @@ * $Date$ - */ + */ @@ -26,3 +26,3 @@ Interface::Interface(QObject * parent, const char * name, bool newSatus): QObjec * emit updateInterface - */ + */ void Interface::setStatus(bool newStatus){ @@ -38,3 +38,3 @@ void Interface::setStatus(bool newStatus){ * emit updateInterface - */ + */ void Interface::setAttached(bool isAttached){ @@ -43,3 +43,3 @@ void Interface::setAttached(bool isAttached){ }; - + /** @@ -48,3 +48,3 @@ void Interface::setAttached(bool isAttached){ * emit updateInterface - */ + */ void Interface::setHardwareName(const QString &name){ @@ -53,3 +53,3 @@ void Interface::setHardwareName(const QString &name){ }; - + /** @@ -58,3 +58,3 @@ void Interface::setHardwareName(const QString &name){ * emit updateInterface - */ + */ void Interface::setModuleOwner(Module *owner){ @@ -67,5 +67,5 @@ void Interface::setModuleOwner(Module *owner){ * Try to start the interface. - */ + */ void Interface::start(){ - // check to see if we are already running. + // check to see if we are already running. if(true == status){ @@ -74,3 +74,3 @@ void Interface::start(){ } - + int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); @@ -91,3 +91,3 @@ void Interface::start(){ void Interface::stop(){ - // check to see if we are already stopped. + // check to see if we are already stopped. if(false == status){ @@ -96,3 +96,3 @@ void Interface::stop(){ } - + int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); @@ -110,3 +110,3 @@ void Interface::stop(){ * Try to restart the interface. - */ + */ void Interface::restart(){ @@ -135,5 +135,5 @@ bool Interface::refresh(){ } - + QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); - int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); + int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); if(ret != 0){ @@ -142,3 +142,3 @@ bool Interface::refresh(){ } - + QFile file(fileName); @@ -154,3 +154,3 @@ bool Interface::refresh(){ broadcast = ""; - + QTextStream stream( &file ); @@ -187,3 +187,3 @@ bool Interface::refresh(){ dhcp = false; - + QString dhcpDirectory(DHCP_INFO_DIR); @@ -192,4 +192,4 @@ bool Interface::refresh(){ dhcpDirectory = "/var/run"; - - // See if we have + + // See if we have QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); @@ -200,3 +200,3 @@ bool Interface::refresh(){ } - + file.setName(dhcpFile); @@ -206,3 +206,3 @@ bool Interface::refresh(){ } - + // leaseTime and renewalTime and used if pid and deamon exe can be accessed. @@ -210,3 +210,3 @@ bool Interface::refresh(){ int renewalTime = 0; - + stream.setDevice( &file ); @@ -224,3 +224,3 @@ bool Interface::refresh(){ //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); - + // Get the pid of the deamond @@ -246,3 +246,3 @@ bool Interface::refresh(){ - // Get the start running time of the deamon + // Get the start running time of the deamon fileName = (QString("/proc/%1/stat").arg(pid)); @@ -259,3 +259,3 @@ bool Interface::refresh(){ long time = 0; - // Grab the start time + // Grab the start time // pid com state ppid pgrp session tty_nr tpgid flags @@ -267,3 +267,3 @@ bool Interface::refresh(){ time = time/100; - + QDateTime datetime(QDateTime::currentDateTime()); @@ -283,15 +283,15 @@ bool Interface::refresh(){ } - + datetime = datetime.addSecs(time); //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); - - // Calculate the start and renew times + + // Calculate the start and renew times leaseObtained = datetime.toString(); - - // Calculate the start and renew times + + // Calculate the start and renew times datetime = datetime.addSecs(leaseTime); leaseExpires = datetime.toString(); - + dhcp = true; - + emit(updateInterface(this)); diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h index 7e98deb..ec82851 100644 --- a/noncore/settings/networksettings/interfaces/interface.h +++ b/noncore/settings/networksettings/interfaces/interface.h @@ -14,9 +14,9 @@ signals: void updateMessage(const QString &message); - + public: Interface(QObject * parent=0, const char * name= "unknown", bool status = false); - + QString getInterfaceName() const { QString n(this->name()); return n; }; void setInterfaceName( const QString &n ) { this->setName(n); }; - + bool getStatus() const { return status; }; @@ -26,6 +26,6 @@ public: void setAttached(bool isAttached=false); - + QString getHardwareName() const { return hardwareName; }; void setHardwareName(const QString &name="Unknown"); - + Module* getModuleOwner() const { return moduleOwner; }; @@ -49,3 +49,3 @@ public: -private: +protected: // Interface information diff --git a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui index 2e106cb..12dbb1d 100644 --- a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui +++ b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui @@ -20,3 +20,3 @@ <size> - <width>240</width> + <width>32767</width> <height>32767</height> diff --git a/noncore/settings/networksettings/interfaces/interfaceinformation.ui b/noncore/settings/networksettings/interfaces/interfaceinformation.ui index 763ad90..207200e 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformation.ui +++ b/noncore/settings/networksettings/interfaces/interfaceinformation.ui @@ -14,3 +14,3 @@ <width>219</width> - <height>255</height> + <height>323</height> </rect> @@ -21,6 +21,12 @@ </property> - <grid> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> <property stdset="1"> <name>margin</name> - <number>11</number> + <number>4</number> </property> @@ -28,77 +34,5 @@ <name>spacing</name> - <number>6</number> + <number>3</number> </property> - <widget row="4" column="0" rowspan="1" colspan="2" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout1</cstring> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget row="1" column="0" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>refreshButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>&Refresh</string> - </property> - </widget> - <widget row="0" column="1" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>stopButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>S&top</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>restartButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>R&estart</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>startButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>&Start</string> - </property> - </widget> - </grid> - </widget> - <widget row="0" column="0" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>Line1</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - <widget row="0" column="0" > + <widget> <class>QLabel</class> @@ -113,3 +47,3 @@ </widget> - <widget row="1" column="0" > + <widget> <class>QLabel</class> @@ -117,14 +51,11 @@ <name>name</name> - <cstring>TextLabel23</cstring> + <cstring>ipAddressLabel</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Subnet Mask</string> + <name>frameShape</name> + <enum>Panel</enum> </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> <property stdset="1"> - <name>name</name> - <cstring>TextLabel21</cstring> + <name>frameShadow</name> + <enum>Sunken</enum> </property> @@ -132,18 +63,21 @@ <name>text</name> - <string>MAC Address</string> + <string>0.0.0.0</string> </property> </widget> - <widget row="3" column="0" > - <class>QLabel</class> + <widget> + <class>Line</class> <property stdset="1"> <name>name</name> - <cstring>TextLabel24</cstring> + <cstring>Line1</cstring> </property> <property stdset="1"> - <name>frameShape</name> - <enum>MShape</enum> + <name>orientation</name> + <enum>Horizontal</enum> </property> + </widget> + <widget> + <class>QLabel</class> <property stdset="1"> - <name>frameShadow</name> - <enum>MShadow</enum> + <name>name</name> + <cstring>TextLabel23</cstring> </property> @@ -151,6 +85,6 @@ <name>text</name> - <string>Broadcast</string> + <string>Subnet Mask</string> </property> </widget> - <widget row="1" column="1" > + <widget> <class>QLabel</class> @@ -173,3 +107,3 @@ </widget> - <widget row="2" column="1" > + <widget> <class>QLabel</class> @@ -192,3 +126,14 @@ </widget> - <widget row="3" column="1" > + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel21</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>MAC Address</string> + </property> + </widget> + <widget> <class>QLabel</class> @@ -211,3 +156,3 @@ </widget> - <widget row="0" column="1" > + <widget> <class>QLabel</class> @@ -215,3 +160,3 @@ <name>name</name> - <cstring>ipAddressLabel</cstring> + <cstring>TextLabel24</cstring> </property> @@ -219,3 +164,3 @@ <name>frameShape</name> - <enum>Panel</enum> + <enum>MShape</enum> </property> @@ -223,3 +168,3 @@ <name>frameShadow</name> - <enum>Sunken</enum> + <enum>MShadow</enum> </property> @@ -227,27 +172,78 @@ <name>text</name> - <string>0.0.0.0</string> + <string>Broadcast</string> </property> </widget> - <spacer row="7" column="1" > - <property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> <name>name</name> - <cstring>Spacer18</cstring> + <cstring>Layout1</cstring> </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget row="1" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>refreshButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Refresh</string> + </property> + </widget> + <widget row="0" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>stopButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>S&top</string> + </property> + </widget> + <widget row="1" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>restartButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>R&estart</string> + </property> + </widget> + <widget row="0" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>startButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Start</string> + </property> + </widget> + </grid> + </widget> + <widget> + <class>Line</class> <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> + <name>name</name> + <cstring>Line5</cstring> </property> <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> + <name>orientation</name> + <enum>Horizontal</enum> </property> - </spacer> - <widget row="6" column="0" rowspan="1" colspan="2" > + </widget> + <widget> <class>QLayoutWidget</class> @@ -300,7 +296,6 @@ </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>Line</class> - <property stdset="1"> + <spacer> + <property> <name>name</name> - <cstring>Line5</cstring> + <cstring>Spacer18</cstring> </property> @@ -308,6 +303,28 @@ <name>orientation</name> - <enum>Horizontal</enum> + <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> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>CheckBoxSilent</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>be &silent</string> </property> </widget> - </grid> + </vbox> </widget> diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp index e00dcce..37c3a91 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp @@ -3,2 +3,3 @@ +#include <qcheckbox.h> #include <qpushbutton.h> @@ -8,3 +9,5 @@ -#ifdef QWS +#include <qpe/config.h> + +#ifdef QWS #else @@ -16,3 +19,3 @@ * 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){ @@ -26,2 +29,12 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); + Config cfg("networksettings", Config::User); + cfg.setGroup("interface"); + CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); +} + +InterfaceInformationImp::~InterfaceInformationImp() +{ + Config cfg("networksettings", Config::User); + cfg.setGroup("interface"); + cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); } @@ -32,3 +45,3 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na * know about). - */ + */ void InterfaceInformationImp::updateInterface(Interface *){ @@ -53,3 +66,3 @@ void InterfaceInformationImp::updateInterface(Interface *){ * Display it. - */ + */ void InterfaceInformationImp::advanced(){ @@ -72,4 +85,5 @@ void InterfaceInformationImp::advanced(){ * @param message the message to display. - */ + */ void InterfaceInformationImp::showMessage(const QString &message){ + if (CheckBoxSilent->isChecked()) return; QMessageBox::information(this, "Message", message, QMessageBox::Ok); diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h index 65cdfe0..9c93d1d 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h @@ -12,3 +12,3 @@ public: InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); - ~InterfaceInformationImp(){}; + ~InterfaceInformationImp(); diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 71d0cf5..436e449 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp @@ -2,2 +2,3 @@ +#include <qcheckbox.h> #include <qfile.h> @@ -153,2 +154,3 @@ bool Interfaces::isInterfaceSet() const { bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ + qDebug("Interfaces::addInterface(%s)",interface.latin1()); if(0 == acceptedFamily.contains(family)) @@ -168,2 +170,3 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ + qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); if(!setInterface(interface)) @@ -274,2 +277,3 @@ QString Interfaces::getInterfaceMethod(bool &error){ bool Interfaces::setInterfaceName(const QString &newName){ + qDebug("setInterfaceName %s", newName.latin1()); if(currentIface == interfaces.end()) @@ -279,3 +283,6 @@ bool Interfaces::setInterfaceName(const QString &newName){ bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); + QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); + qDebug("setting %s",tmp.latin1()); + + (*currentIface) = tmp; return !returnValue; @@ -329,2 +336,4 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ * doesn't exist then it is added along with the value. + * If value isEmpty() then we will remove the option + * * @param option the options to set the value. @@ -335,3 +344,7 @@ QString Interfaces::getInterfaceOption(const QString &option, bool &error){ bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ - return setOption(currentIface, option, value); + if( value.stripWhiteSpace().isEmpty() ) + return removeInterfaceOption( option ); + + qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1()); + return setOption(currentIface, option, value); } @@ -494,15 +507,27 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op return false; - + qDebug("setting option"); bool found = false; + bool replaced = false; + QStringList::Iterator insertAt = NULL; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - if(!found && value != ""){ - // Got to the end of the stanza without finding it, so append it. - interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); - } - found = true; - break; - } + qDebug(" Interfaces::setOption got line >%s<",(*it).latin1()); + // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line + // but since it works with an empty interfaces file I (tille) will not do anything more + if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){ + if (found) break; +// && it != start){ +// if(!found && value != ""){ +// // Got to the end of the stanza without finding it, so append it. +// qDebug(" Got to the end of the stanza without finding it, so append it."); +// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); +// } + qDebug("found 1"); +// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value)); + found = true; + insertAt = it; + + } if((*it).contains(option) && it != start && (*it).at(0) != '#'){ // Found it in stanza so replace it. + qDebug("found 2"); if(found) @@ -510,2 +535,3 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op found = true; + replaced = true; (*it) = QString("\t%1 %2").arg(option).arg(value); @@ -514,2 +540,3 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op if(!found){ + qDebug("! found insert anyway"); QStringList::Iterator p = start; @@ -518,2 +545,7 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op } + + if(found && !replaced){ + qDebug("found iface but not the option so insert it here..."); + interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value)); + } return found; @@ -554,3 +586,4 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString found = true; - (*it) = ""; + it = interfaces.remove( it ); // we really want to remove the line + --it; // we do ++it later in the head of the for loop } @@ -581,3 +614,4 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString found = true; - (*it) = ""; + it = interfaces.remove( it ); // we really want to remove the line + --it; // we do ++it later in the head of the for loop } diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index b40d101..e844d8a 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp @@ -46,2 +46,3 @@ bool InterfaceSetupImp::saveChanges(){ QString iface = interfaces->getInterfaceName(error); + qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); if(!saveSettings()) @@ -119,2 +120,5 @@ bool InterfaceSetupImp::saveSettings(){ interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); + }else{ + interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); + interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); } |