46 files changed, 116 insertions, 5146 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index d61c510..c83d909 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO @@ -1,8 +1,10 @@ +Make sure the C code in wextensions is clean. + WLAN needs to be re-written to not use Config WHERE Is DHCP info stored??? PPP module needs to be written Write a class that parses /proc and not ifconfig Possible other modules: ipsec, bluetooth, ipchains diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp deleted file mode 100644 index 929b3a1..0000000 --- a/noncore/net/networksetup/interface.cpp +++ b/dev/null @@ -1,287 +0,0 @@ -#include "interface.h" -#include <qdatetime.h> -#include <qfile.h> -#include <qdir.h> -#include <qfileinfo.h> -#include <qtextstream.h> - -#define IFCONFIG "/sbin/ifconfig" -#define DHCP_INFO_DIR "/etc/dhcpc" - -#include <stdio.h> -#include <stdlib.h> - -Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ - refresh(); -} - -/** - * Set status - * @param newStatus - the new status - * emit updateInterface - */ -void Interface::setStatus(bool newStatus){ - if(status != newStatus){ - status = newStatus; - refresh(); - } -}; - -/** - * Set if attached or not (802.11 card pulled out for example) - * @param isAttached - if attached - * emit updateInterface - */ -void Interface::setAttached(bool isAttached){ - attached = isAttached; - emit(updateInterface(this)); -}; - -/** - * Set Hardware name - * @param name - the new name - * emit updateInterface - */ -void Interface::setHardwareName(QString name){ - hardwareName = name; - emit(updateInterface(this)); -}; - -/** - * Set Module owner - * @param owner - the new owner - * emit updateInterface - */ -void Interface::setModuleOwner(Module *owner){ - moduleOwner = owner; - emit(updateInterface(this)); -}; - - -/** - * Try to start the interface. - */ -void Interface::start(){ - // check to see if we are already running. - if(true == status) - return; - - int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); - // See if it was successfull... - if(ret != 0) - return; - - status = true; - refresh(); -} - -/** - * Try to stop the interface. - */ -void Interface::stop(){ - // check to see if we are already stopped. - if(false == status) - return; - - int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); - if(ret != 0) - return; - - status = true; - refresh(); -} - -/** - * Try to restart the interface. - */ -void Interface::restart(){ - stop(); - start(); -} - -/** - * Try to refresh the information about the interface. - * First call ifconfig, then check the dhcp-info file - * @return bool true if successfull. - */ -bool Interface::refresh(){ - // See if we are up. - if(status == false){ - macAddress = ""; - ip = "0.0.0.0"; - subnetMask = "0.0.0.0"; - broadcast = ""; - dhcp = false; - dhcpServerIp = ""; - leaseObtained = ""; - leaseExpires = ""; - emit(updateInterface(this)); - return true; - } - - 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()); - if(ret != 0){ - qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); - return false; - } - - QFile file(fileName); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); - return false; - } - - // Set to the defaults - macAddress = ""; - ip = "0.0.0.0"; - subnetMask = "0.0.0.0"; - broadcast = ""; - - QTextStream stream( &file ); - QString line; - while ( !stream.eof() ) { - line = stream.readLine(); - if(line.contains("HWaddr")){ - int mac = line.find("HWaddr"); - macAddress = line.mid(mac+7, line.length()); - } - if(line.contains("inet addr")){ - int ipl = line.find("inet addr"); - int space = line.find(" ", ipl+10); - ip = line.mid(ipl+10, space-ipl-10); - } - if(line.contains("Mask")){ - int mask = line.find("Mask"); - subnetMask = line.mid(mask+5, line.length()); - } - if(line.contains("Bcast")){ - int mask = line.find("Bcast"); - int space = line.find(" ", mask+6); - broadcast = line.mid(mask+6, space-mask-6); - } - } - file.close(); - QFile::remove(fileName); - - // DHCP TESTING - // reset DHCP info - dhcpServerIp = ""; - leaseObtained = ""; - leaseExpires = ""; - dhcp = false; - - QString dhcpDirectory(DHCP_INFO_DIR); - QDir d(dhcpDirectory); - if(!d.exists(dhcpDirectory)) - dhcpDirectory = "/var/run"; - - // See if we have - QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); - // If there is no DHCP information then exit now with no errors. - if(!QFile::exists(dhcpFile)){ - emit(updateInterface(this)); - return true; - } - - file.setName(dhcpFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); - return false; - } - - // leaseTime and renewalTime and used if pid and deamon exe can be accessed. - int leaseTime = 0; - int renewalTime = 0; - - stream.setDevice( &file ); - while ( !stream.eof() ) { - line = stream.readLine(); - if(line.contains("DHCPSIADDR=")) - dhcpServerIp = line.mid(11, line.length()); - if(line.contains("LEASETIME=")) - leaseTime = line.mid(10, line.length()).toInt(); - if(line.contains("RENEWALTIME=")) - renewalTime = line.mid(12, line.length()).toInt(); - } - file.close(); - //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); - //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); - - // Get the pid of the deamond - dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); - file.setName(dhcpFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); - return false; - } - - int pid = -1; - stream.setDevice( &file ); - while ( !stream.eof() ) { - line = stream.readLine(); - pid = line.toInt(); - } - file.close(); - - if( pid == -1){ - qDebug("Interface: Could not get pid of dhcpc deamon."); - return false; - } - - // Get the start running time of the deamon - fileName = (QString("/proc/%1/stat").arg(pid)); - file.setName(fileName); - stream.setDevice( &file ); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); - return false; - } - while ( !stream.eof() ) { - line = stream.readLine(); - } - file.close(); - long time = 0; - // Grab the start time - // pid com state ppid pgrp session tty_nr tpgid flags - sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " - // minflt cminflt majflt cmajflt utime stime cutime cstime priority - "%*u %*u %*u %*u %*u %*u %*d %*d %*d " - // nice 0 itrealvalue starttime - "%*d %*d %*d %lu", (long*) &time); - time = time/100; - - QDateTime datetime(QDateTime::currentDateTime()); - - // Get the uptime of the computer. - QFile f("/proc/uptime"); - if ( f.open(IO_ReadOnly) ) { // file opened successfully - QTextStream t( &f ); // use a text stream - int sec = 0; - t >> sec; - datetime = datetime.addSecs((-1*sec)); - f.close(); - } - else{ - qDebug("Interface: Can't open /proc/uptime to retrive uptime."); - return false; - } - - datetime = datetime.addSecs(time); - //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); - - // Calculate the start and renew times - leaseObtained = datetime.toString(); - - // Calculate the start and renew times - datetime = datetime.addSecs(leaseTime); - leaseExpires = datetime.toString(); - - dhcp = true; - - emit(updateInterface(this)); - return true; -} - -// interface.cpp - diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h deleted file mode 100644 index dc9c6d3..0000000 --- a/noncore/net/networksetup/interface.h +++ b/dev/null @@ -1,71 +0,0 @@ -#ifndef INTERFACE_H -#define INTERFACE_H - -#include <qstring.h> -#include <qobject.h> - -class Module; - -class Interface : public QObject{ - Q_OBJECT - -signals: - void updateInterface(Interface *i); - -public: - Interface(QObject * parent=0, const char * name= "unknown", bool status = false); - virtual ~Interface(){}; - - virtual QString getInterfaceName(){ QString n(this->name()); return n; }; - - virtual bool getStatus(){ return status; }; - virtual void setStatus(bool newStatus); - - virtual bool isAttached(){ return attached; }; - virtual void setAttached(bool isAttached=false); - - virtual QString getHardwareName(){ return hardwareName; }; - virtual void setHardwareName(QString name="Unknown"); - - virtual Module* getModuleOwner(){ return moduleOwner; }; - virtual void setModuleOwner(Module *owner=NULL); - - // inet information. - QString getMacAddress(){ return macAddress; }; - QString getIp(){ return ip; }; - QString getSubnetMask(){ return subnetMask; }; - QString getBroadcast(){ return broadcast; }; - bool isDhcp(){ return dhcp; }; - QString getDhcpServerIp(){ return dhcpServerIp; }; - QString getLeaseObtained(){ return leaseObtained; }; - QString getLeaseExpires(){ return leaseExpires; }; - -public slots: - bool refresh(); - void start(); - void stop(); - void restart(); - -private: - // Interface information - bool status; - bool attached; - QString hardwareName; - Module *moduleOwner; - - // Network information - QString macAddress; - QString ip; - QString broadcast; - QString subnetMask; - bool dhcp; - QString dhcpServerIp; - QString leaseObtained; - QString leaseExpires; - -}; - -#endif - -// interface.h - diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui deleted file mode 100644 index 0ec67c2..0000000 --- a/noncore/net/networksetup/interfaceadvanced.ui +++ b/dev/null @@ -1,344 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceAdvanced</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>InterfaceAdvanced</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>214</width> - <height>286</height> - </rect> - </property> - <property stdset="1"> - <name>maximumSize</name> - <size> - <width>240</width> - <height>32767</height> - </size> - </property> - <property stdset="1"> - <name>caption</name> - <string>Advanced Interface Information</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>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>MAC Address</string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>interfaceName</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>eth0</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>macAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>00:00:00:00:00:00</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel7</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Interface</string> - </property> - </widget> - <widget row="4" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>Subnet Mask</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>ipAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="4" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>subnetMaskLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Broadcast</string> - </property> - </widget> - <widget row="3" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>broadcastLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>QGroupBox</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpInformation</cstring> - </property> - <property stdset="1"> - <name>title</name> - <string>DHCP Information</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="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel6</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>DHCP Server</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseExpiresLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseObtainedLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel9</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Lease Expires</string> - </property> - </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel8</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Lease Obtained</string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpServerLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - </grid> - </widget> - <spacer row="6" column="1" > - <property> - <name>name</name> - <cstring>Spacer2</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> - </grid> -</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> -</UI> diff --git a/noncore/net/networksetup/interfaceedit.cpp b/noncore/net/networksetup/interfaceedit.cpp deleted file mode 100644 index 25599ef..0000000 --- a/noncore/net/networksetup/interfaceedit.cpp +++ b/dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'interfaceedit.ui' -** -** Created: Mon Sep 23 12:18:55 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#include "interfaceedit.h" - -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qframe.h> -#include <qgroupbox.h> -#include <qlabel.h> -#include <qlineedit.h> -#include <qpushbutton.h> -#include <qspinbox.h> -#include "qwidget.h" -#include <qlayout.h> -#include <qvariant.h> -#include <qtooltip.h> -#include <qwhatsthis.h> - -/* - * Constructs a InterfaceConfiguration which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - */ -InterfaceConfiguration::InterfaceConfiguration( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) -{ - if ( !name ) - setName( "InterfaceConfiguration" ); - resize( 177, 306 ); - setCaption( tr( "Interface Configuration" ) ); - InterfaceConfigurationLayout = new QGridLayout( this ); - InterfaceConfigurationLayout->setSpacing( 6 ); - InterfaceConfigurationLayout->setMargin( 11 ); - - profile = new QComboBox( FALSE, this, "profile" ); - profile->insertItem( tr( "All" ) ); - - InterfaceConfigurationLayout->addWidget( profile, 2, 1 ); - - TextLabel1 = new QLabel( this, "TextLabel1" ); - TextLabel1->setText( tr( "Profile:" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel1, 2, 0 ); - - Line1 = new QFrame( this, "Line1" ); - Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - - InterfaceConfigurationLayout->addMultiCellWidget( Line1, 1, 1, 0, 1 ); - - CheckBox3 = new QCheckBox( this, "CheckBox3" ); - CheckBox3->setText( tr( "Automaticly bring up" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( CheckBox3, 0, 0, 0, 1 ); - - dhcpCheckBox = new QCheckBox( this, "dhcpCheckBox" ); - dhcpCheckBox->setText( tr( "DHCP" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( dhcpCheckBox, 3, 3, 0, 1 ); - - TextLabel3_3_2 = new QLabel( this, "TextLabel3_3_2" ); - TextLabel3_3_2->setText( tr( "Lease Hours" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel3_3_2, 4, 0 ); - - SpinBox1_2 = new QSpinBox( this, "SpinBox1_2" ); - SpinBox1_2->setMaxValue( 336 ); - SpinBox1_2->setMinValue( 1 ); - SpinBox1_2->setValue( 24 ); - - InterfaceConfigurationLayout->addWidget( SpinBox1_2, 4, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); - InterfaceConfigurationLayout->addItem( spacer, 11, 1 ); - - TextLabel4 = new QLabel( this, "TextLabel4" ); - TextLabel4->setText( tr( "IP Address" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel4, 6, 0 ); - - ipAddressEdit = new QLineEdit( this, "ipAddressEdit" ); - - InterfaceConfigurationLayout->addWidget( ipAddressEdit, 6, 1 ); - - TextLabel5 = new QLabel( this, "TextLabel5" ); - TextLabel5->setText( tr( "Subnet Mask" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel5, 7, 0 ); - - firstDNSLineEdit = new QLineEdit( this, "firstDNSLineEdit" ); - - InterfaceConfigurationLayout->addWidget( firstDNSLineEdit, 9, 1 ); - - TextLabel3 = new QLabel( this, "TextLabel3" ); - TextLabel3->setText( tr( "Second DNS" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel3, 10, 0 ); - - subnetMaskEdit = new QLineEdit( this, "subnetMaskEdit" ); - - InterfaceConfigurationLayout->addWidget( subnetMaskEdit, 7, 1 ); - - gatewayEdit = new QLineEdit( this, "gatewayEdit" ); - - InterfaceConfigurationLayout->addWidget( gatewayEdit, 8, 1 ); - - TextLabel7 = new QLabel( this, "TextLabel7" ); - TextLabel7->setText( tr( "Gateway" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel7, 8, 0 ); - - TextLabel2 = new QLabel( this, "TextLabel2" ); - TextLabel2->setText( tr( "First DNS" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel2, 9, 0 ); - - secondDNSLineEdit = new QLineEdit( this, "secondDNSLineEdit" ); - - InterfaceConfigurationLayout->addWidget( secondDNSLineEdit, 10, 1 ); - - GroupBox2 = new QGroupBox( this, "GroupBox2" ); - GroupBox2->setTitle( tr( "Static Ip Configuration" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( GroupBox2, 5, 5, 0, 1 ); - - // signals and slots connections - connect( dhcpCheckBox, SIGNAL( toggled(bool) ), SpinBox1_2, SLOT( setEnabled(bool) ) ); - connect( dhcpCheckBox, SIGNAL( toggled(bool) ), GroupBox2, SLOT( setDisabled(bool) ) ); -} - -/* - * Destroys the object and frees any allocated resources - */ -InterfaceConfiguration::~InterfaceConfiguration() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/noncore/net/networksetup/interfaceedit.h b/noncore/net/networksetup/interfaceedit.h deleted file mode 100644 index a65c030..0000000 --- a/noncore/net/networksetup/interfaceedit.h +++ b/dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'interfaceedit.ui' -** -** Created: Mon Sep 23 12:18:55 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#ifndef INTERFACECONFIGURATION_H -#define INTERFACECONFIGURATION_H - -#include <qvariant.h> -#include <qwidget.h> -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QCheckBox; -class QComboBox; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QSpinBox; - -class InterfaceConfiguration : public QWidget -{ - Q_OBJECT - -public: - InterfaceConfiguration( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); - ~InterfaceConfiguration(); - - QComboBox* profile; - QLabel* TextLabel1; - QFrame* Line1; - QCheckBox* CheckBox3; - QCheckBox* dhcpCheckBox; - QLabel* TextLabel3_3_2; - QSpinBox* SpinBox1_2; - QLabel* TextLabel4; - QLineEdit* ipAddressEdit; - QLabel* TextLabel5; - QLineEdit* firstDNSLineEdit; - QLabel* TextLabel3; - QLineEdit* subnetMaskEdit; - QLineEdit* gatewayEdit; - QLabel* TextLabel7; - QLabel* TextLabel2; - QLineEdit* secondDNSLineEdit; - QGroupBox* GroupBox2; - -protected: - QGridLayout* InterfaceConfigurationLayout; -}; - -#endif // INTERFACECONFIGURATION_H diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui deleted file mode 100644 index 2838d19..0000000 --- a/noncore/net/networksetup/interfaceinformation.ui +++ b/dev/null @@ -1,343 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceInformation</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>InterfaceInformation</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>219</width> - <height>255</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Interface Information</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="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" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel22</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel23</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Subnet Mask</string> - </property> - </widget> - <widget row="2" column="0" > - <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 row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel24</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>MShape</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>MShadow</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>Broadcast</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>subnetMaskLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>macAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>00:00:00:00:00:00</string> - </property> - </widget> - <widget row="3" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>broadcastLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>ipAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <spacer row="7" column="1" > - <property> - <name>name</name> - <cstring>Spacer18</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> - <widget row="6" column="0" rowspan="1" colspan="2" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout2</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <spacer> - <property> - <name>name</name> - <cstring>Spacer10</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</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>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>advancedButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>View &Advanced Information</string> - </property> - </widget> - </hbox> - </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>Line5</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - </grid> -</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> -<tabstops> - <tabstop>startButton</tabstop> - <tabstop>stopButton</tabstop> - <tabstop>refreshButton</tabstop> - <tabstop>restartButton</tabstop> - <tabstop>advancedButton</tabstop> -</tabstops> -</UI> diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp deleted file mode 100644 index 43483fb..0000000 --- a/noncore/net/networksetup/interfaceinformationimp.cpp +++ b/dev/null @@ -1,70 +0,0 @@ -#include "interfaceinformationimp.h" -#include "interfaceadvanced.h" - -#include <qpushbutton.h> -#include <qlabel.h> -#include <qgroupbox.h> -#include <assert.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){ - assert(i); - - interface = i; - connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); - 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){ - 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(); -} - -// infoimp.cpp - diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h deleted file mode 100644 index 42213cc..0000000 --- a/noncore/net/networksetup/interfaceinformationimp.h +++ b/dev/null @@ -1,27 +0,0 @@ -#ifndef INTERFACEINFORMATIONIMP_H -#define INTERFACEINFORMATIONIMP_H - -#include "interfaceinformation.h" -#include "interface.h" - -class InterfaceInformationImp : public InterfaceInformation { - -Q_OBJECT - -public: - InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); - ~InterfaceInformationImp(){}; - -private slots: - void advanced(); - void updateInterface(Interface *i); - -private: - Interface *interface; - -}; - -#endif - -// addserviceimp.h - diff --git a/noncore/net/networksetup/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp deleted file mode 100644 index 377a6db..0000000 --- a/noncore/net/networksetup/interfaces.cpp +++ b/dev/null @@ -1,638 +0,0 @@ -#include "interfaces.h" - -#include <qfile.h> -#include <qtextstream.h> -#include <qregexp.h> - -#define AUTO "auto" -#define IFACE "iface" -#define MAPPING "mapping" - -/** - * Constructor. Reads in the interfaces file and then split the file up by - * the \n for interfaces variable. - * @param useInterfacesFile if an interface file other then the default is - * desired to be used it should be passed in. - */ -Interfaces::Interfaces(QString useInterfacesFile){ - acceptedFamily.append(INTERFACES_FAMILY_INET); - acceptedFamily.append(INTERFACES_FAMILY_IPX); - acceptedFamily.append(INTERFACES_FAMILY_INET6); - - interfacesFile = useInterfacesFile; - QFile file(interfacesFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); - currentIface = interfaces.end(); - currentMapping = interfaces.end(); - return; - } - QTextStream stream( &file ); - QString line; - while ( !stream.eof() ) { - line += stream.readLine(); - line += "\n"; - } - file.close(); - interfaces = QStringList::split("\n", line, true); - - currentIface = interfaces.end(); - currentMapping = interfaces.end(); -} - - -/** - * Get a list of all interfaces in the interface file. Usefull for - * hardware that is not currently connected such as an 802.11b card - * not plugged in, but configured for when it is plugged in. - * @return Return string list of interfaces. - **/ -QStringList Interfaces::getInterfaceList(){ - QStringList list; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - if(line.contains(IFACE) && line.at(0) != '#'){ - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace >= 0){ - line = line.mid(0, findSpace); - list.append(line); - } - } - } - return list; -} - -/** - * Find out if interface is in an "auto" group or not. - * Report any duplicates such as eth0 being in two differnt auto's - * @param interface interface to check to see if it is on or not. - * @return true is interface is in auto - */ -bool Interfaces::isAuto(QString interface){ - QStringList autoLines = interfaces.grep(QRegExp(AUTO)); - QStringList awi = autoLines.grep(QRegExp(interface)); - if(awi.count() > 1) - qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); - if(awi.count() < 1) - return false; - return true; -} - -/** - * Attempt to set the auto option for interface to setAuto. - * @param interface the interface to set - * @param setAuto the value to set interface to. - * @return false if already set to setAuto. - * */ -bool Interfaces::setAuto(QString interface, bool setAuto){ - // Don't need to set it if it is already set. - if(isAuto(interface) == setAuto) - return false; - - bool changed = false; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - if((*it).contains(AUTO)){ - //We know that they are not in any group so let add to this auto. - if(setAuto){ - (*it) = (*it) += " " + interface; - // Don't care to have such thins as: auto eth0 lo usb0 - (*it) = (*it).simplifyWhiteSpace(); - changed = true; - break; - } - else{ - if((*it).contains(interface)){ - (*it) = (*it).replace(QRegExp(interface), ""); - // clean up - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line == AUTO) - (*it) = ""; - changed = true; - // Don't break because we want to make sure we remove all cases. - } - } - } - } - if(changed == false){ - if(setAuto == true) - interfaces.append(QString(AUTO" %1").arg(interface)); - else{ - qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); - } - } - return true; -} - -/** - * Set the current interface to interface. This needs to be done before you - * can call getFamily(), getMethod, and get/setOption(). - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @return bool true if it is successfull. - */ -bool Interfaces::setInterface(QString interface){ - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - return setStanza(IFACE, interface, currentIface); -} - -/** - * A quick helper funtion to see if the current interface is set. - * @return bool true if set, false otherwise. - */ -bool Interfaces::isInterfaceSet(){ - return (currentIface != interfaces.end()); -} - -/** - * Add a new interface of with the settings - family and method - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @param family the family of this interface inet or inet, ipx or inet6 - * Must of one of the families defined in interfaces.h - * @param method for the family. see interfaces man page for family methods. - * @return true if successfull. - */ -bool Interfaces::addInterface(QString interface, QString family, QString method){ - if(acceptedFamily.contains(family)==0) - return false; - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - interfaces.append(""); - interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); - return true; -} - -/** - * Copies interface with name interface to name newInterface - * @param newInterface name of the new interface. - * @return bool true if successfull - */ -bool Interfaces::copyInterface(QString interface, QString newInterface){ - if(!setInterface(interface)) return false; - - QStringList::Iterator it = currentIface; - it++; - - bool error; - addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); - if(!setInterface(newInterface)) return false; - QStringList::Iterator newIface = currentIface; - newIface++; - - for ( it; it != interfaces.end(); ++it ){ - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) - break; - newIface = interfaces.insert(newIface, *it); - } - - return true; -} - -/** - * Remove the currently selected interface and all of its options. - * @return bool if successfull or not. - */ -bool Interfaces::removeInterface(){ - if(currentIface == interfaces.end()) - return false; - (*currentIface) = ""; - return removeAllInterfaceOptions(); -} - -/** - * Gets the hardware name of the interface that is currently selected. - * @return QString name of the hardware interface (eth0, usb2, wlan1...). - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceName(bool &error){ - if(currentIface == interfaces.end()){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace < 0){ - error = true; - return QString(); - } - error = false; - return line.mid(0, findSpace); -} - -/** - * Gets the family name of the interface that is currently selected. - * @return QString name of the family (inet, inet6, ipx). - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceFamily(bool &error){ - QString name = getInterfaceName(error); - if(error){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.mid(name.length()+1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace < 0){ - error = true; - return QString(); - } - error = false; - return line.mid(0, findSpace); -} - -/** - * Gets the method of the interface that is currently selected. - * @return QString name of the method such as staic or dhcp. - * See the man page of interfaces for possible methods depending on the family. - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceMethod(bool &error){ - QString name = getInterfaceName(error); - if(error){ - error = true; - return QString(); - } - QString family = getInterfaceFamily(error); - if(error){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length()+1, line.length()); - line = line.mid(name.length()+1, line.length()); - line = line.mid(family.length()+1, line.length()); - line = line.simplifyWhiteSpace(); - error = false; - return line; -} - -/** - * Sets the interface name to newName. - * @param newName the new name of the interface. All whitespace is removed. - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceName(QString newName){ - if(currentIface == interfaces.end()) - return false; - newName = newName.simplifyWhiteSpace(); - newName = newName.replace(QRegExp(" "), ""); - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); - return !returnValue; -} - -/** - * Sets the interface family to newName. - * @param newName the new name of the interface. Must be one of the families - * defined in the interfaces.h file. - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceFamily(QString newName){ - if(currentIface == interfaces.end()) - return false; - if(acceptedFamily.contains(newName)==0) - return false; - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); - return !returnValue; -} - -/** - * Sets the interface method to newName - * @param newName the new name of the interface - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceMethod(QString newName){ - if(currentIface == interfaces.end()) - return false; - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); - return !returnValue; -} - -/** - * Get a value for an option in the currently selected interface. For example - * calling getInterfaceOption("address") on the following stanza would - * return 192.168.1.1. - * iface eth0 static - * address 192.168.1.1 - * @param option the options to get the value. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -QString Interfaces::getInterfaceOption(QString option, bool &error){ - return getOption(currentIface, option, error); -} - -/** - * Set a value for an option in the currently selected interface. If option - * doesn't exist then it is added along with the value. - * @param option the options to set the value. - * @param value the value that option should be set to. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -bool Interfaces::setInterfaceOption(QString option, QString value){ - return setOption(currentIface, option, value); -} - -/** - * Removes a value for an option in the currently selected interface. - * @param option the options to set the value. - * @param value the value that option should be set to. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -bool Interfaces::removeInterfaceOption(QString option, QString value){ - return removeOption(currentIface, option, value); -} - -/** - * Removes all of the options from the currently selected interface. - * @return bool error if if successfull - */ -bool Interfaces::removeAllInterfaceOptions(){ - return removeAllOptions(currentIface); -} - -/** - * Set the current map to interface's map. This needs to be done before you - * can call addMapping(), set/getMap(), and get/setScript(). - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @return bool true if it is successfull. - */ -bool Interfaces::setMapping(QString interface){ - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - return setStanza(MAPPING, interface, currentMapping); -} - -/** - * Adds a new Mapping to the interfaces file with interfaces. - * @param interface the name(s) of the interfaces to set to this mapping - */ -void Interfaces::addMapping(QString option){ - interfaces.append(""); - interfaces.append(QString(MAPPING " %1").arg(option)); -} - -/** - * Remove the currently selected map and all of its options. - * @return bool if successfull or not. - */ -bool Interfaces::removeMapping(){ - if(currentMapping == interfaces.end()) - return false; - (*currentMapping) = ""; - return removeAllOptions(currentMapping); -} - -/** - * Set a map option within a mapping. - * @param map map to use - * @param value value to go with map - * @return bool true if it is successfull. - */ -bool Interfaces::setMap(QString map, QString value){ - return setOption(currentMapping, map, value); -} - -/** - * Removes a map option within a mapping. - * @param map map to use - * @param value value to go with map - * @return bool true if it is successfull. - */ -bool Interfaces::removeMap(QString map, QString value){ - return removeOption(currentMapping, map, value); -} - -/** - * Get a map value within a mapping. - * @param map map to get value of - * @param bool true if it is successfull. - * @return value that goes to the map - */ -QString Interfaces::getMap(QString map, bool &error){ - return getOption(currentMapping, map, error); -} - -/** - * Sets a script value of the current mapping to argument. - * @param argument the script name. - * @return true if successfull. - */ -bool Interfaces::setScript(QString argument){ - return setOption(currentMapping, "script", argument); -} - -/** - * @param error true if could not retrieve the current script argument. - * @return QString the argument of the script for the current mapping. - */ -QString Interfaces::getScript(bool &error){ - return getOption(currentMapping, "script", error); -} - -/** - * Helper function used to parse through the QStringList and put pointers in - * the correct place. - * @param stanza The stanza (auto, iface, mapping) to look for. - * @param option string that must be in the stanza's main line. - * @param interator interator to place at location of stanza if successfull. - * @return bool true if the stanza is found. - */ -bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ - bool found = false; - iterator = interfaces.end(); - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ - uint point = line.find(option); - bool valid = true; - if(point > 0){ - // There are more chars in the line. check +1 - if(line.at(point-1) != ' ') - valid = false; - } - point += option.length(); - if(point < line.length()-1){ - // There are more chars in the line. check -1 - if(line.at(point) != ' ') - valid = false; - } - if(valid){ - if(found == true){ - qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); - } - found = true; - iterator = it; - } - } - } - return found; -} - -/** - * Sets a value of an option in a stanza - * @param start the start of the stanza - * @param option the option to use when setting value. - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ - if(start == interfaces.end()) - return false; - - bool found = false; - 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; - } - if((*it).contains(option) && it != start && (*it).at(0) != '#'){ - // Found it in stanza so replace it. - if(found) - qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); - found = true; - (*it) = QString("\t%1 %2").arg(option).arg(value); - } - } - if(!found){ - QStringList::Iterator p = start; - interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); - found = true; - } - return found; -} -/** - * Removes a option in a stanza - * @param start the start of the stanza - * @param option the option to use when setting value. - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ - if(start == interfaces.end()) - return false; - - bool found = false; - for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - // got to the end without finding it - break; - } - if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ - // Found it in stanza so replace it. - if(found) - qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); - found = true; - (*it) = ""; - } - } - return found; -} - -/** - * Removes all options in a stanza - * @param start the start of the stanza - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::removeAllOptions(QStringList::Iterator start){ - if(start == interfaces.end()) - return false; - - QStringList::Iterator it = start; - it = ++it; - for (it; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - break; - } - it = interfaces.remove(it); - it = --it; - } - // Leave a space between this interface and the next. - interfaces.insert(it, QString("")); - return true; -} - -/** - * Gets a value of an option in a stanza - * @param start the start of the stanza - * @param option the option to use when getting the value. - * @param bool true if errors false otherwise. - * @return QString the value of option QString::null() if error == true. - */ -QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ - if(start == interfaces.end()){ - error = false; - return QString(); - } - - QString value; - bool found = false; - for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - break; - } - if((*it).contains(option) && (*it).at(0) != '#'){ - if(found) - qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); - found = true; - QString line = (*it).simplifyWhiteSpace(); - int space = line.find(" ", option.length()); - if(space != -1) - value = line.mid(space+1, line.length()); - else - qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); - } - } - error = !found; - return value; -} - -/** - * Write out the interfaces file to the file passed into the constructor. - * Removes any excess blank lines over 1 line long. - * @return bool true if successfull, false if not. - */ -bool Interfaces::write(){ - QFile::remove(interfacesFile); - QFile file(interfacesFile); - - if (!file.open(IO_ReadWrite)){ - qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); - return false; - } - QTextStream stream( &file ); - int whiteSpaceCount = 0; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line.length() == 0) - whiteSpaceCount++; - else - whiteSpaceCount = 0; - if(whiteSpaceCount < 2){ - qDebug((*it).latin1()); - stream << (*it) << '\n'; - } - } - file.close(); - return true; -} - -// interfaces.cpp - diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h deleted file mode 100644 index e09ea71..0000000 --- a/noncore/net/networksetup/interfaces.h +++ b/dev/null @@ -1,76 +0,0 @@ -#ifndef INTERFACES_H -#define INTERFACES_H - -#include <qstring.h> -#include <qstringlist.h> - -#define INTERFACES_LOOPBACK "loopback" - -#define INTERFACES_FAMILY_INET "inet" -#define INTERFACES_FAMILY_IPX "ipx" -#define INTERFACES_FAMILY_INET6 "inet6" - -#define INTERFACES_METHOD_DHCP "dhcp" -#define INTERFACES_METHOD_STATIC "static" -#define INTERFACES_METHOD_PPP "ppp" - -/** - * This class provides a clean frontend for parsing the network interfaces file. - * It provides helper functions to minipulate the options within the file. - * See the interfaces man page for the syntax rules. - */ -class Interfaces { - -public: - Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); - QStringList getInterfaceList(); - - bool isAuto(QString interface); - bool setAuto(QString interface, bool setAuto); - - bool removeInterface(); - bool addInterface(QString interface, QString family, QString method); - bool copyInterface(QString oldInterface, QString newInterface); - bool setInterface(QString interface); - bool isInterfaceSet(); - QString getInterfaceName(bool &error); - bool setInterfaceName(QString newName); - QString getInterfaceFamily(bool &error); - bool setInterfaceFamily(QString newName); - QString getInterfaceMethod(bool &error); - bool setInterfaceMethod(QString newName); - QString getInterfaceOption(QString option, bool &error); - bool setInterfaceOption(QString option, QString value); - bool removeInterfaceOption(QString option, QString value); - bool removeAllInterfaceOptions(); - - bool setMapping(QString interface); - bool removeMapping(); - void addMapping(QString options); - bool setMap(QString map, QString value); - bool removeMap(QString map, QString value); - QString getMap(QString map, bool &error); - bool setScript(QString); - QString getScript(bool &error); - - bool write(); - -private: - bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); - bool setOption(QStringList::Iterator start, QString option, QString value); - bool removeOption(QStringList::Iterator start, QString option, QString value); - QString getOption(QStringList::Iterator start, QString option, bool &error); - bool removeAllOptions(QStringList::Iterator start); - - QString interfacesFile; - QStringList interfaces; - QStringList::Iterator currentIface; - QStringList::Iterator currentMapping; - - QStringList acceptedFamily; -}; - -#endif - -// interfaces - diff --git a/noncore/net/networksetup/interfacesetup.ui b/noncore/net/networksetup/interfacesetup.ui deleted file mode 100644 index 0c834fe..0000000 --- a/noncore/net/networksetup/interfacesetup.ui +++ b/dev/null @@ -1,284 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceSetup</class> -<widget> - <class>QDialog</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> - <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> - <property stdset="1"> - <name>name</name> - <cstring>Layout9</cstring> - </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>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> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>First DNS</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1_2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Gateway</string> - </property> - </widget> - <widget row="4" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Second DNS</string> - </property> - </widget> - <widget row="3" column="1" > - <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> -<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/interfacesetupimp.cpp b/noncore/net/networksetup/interfacesetupimp.cpp deleted file mode 100644 index a8731a9..0000000 --- a/noncore/net/networksetup/interfacesetupimp.cpp +++ b/dev/null @@ -1,147 +0,0 @@ -#include "interfacesetupimp.h" -#include "interface.h" -#include "interfaces.h" - -#include <qcombobox.h> -#include <qcheckbox.h> -#include <qlineedit.h> -#include <qspinbox.h> -#include <qgroupbox.h> -#include <qlabel.h> - -#include <qmessagebox.h> - -#include <assert.h> - -#define DNSSCRIPT "interfacednsscript" - -/** - * Constuctor. Set up the connection and load the first profile. - */ -InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ - assert(i); - interface = i; - interfaces = new Interfaces(); - bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - staticGroupBox->hide(); - dhcpCheckBox->hide(); - leaseTime->hide(); - leaseHoursLabel->hide(); - } -} - -/** - * Save the current settings, then write out the interfaces file and close. - */ -void InterfaceSetupImp::accept(){ - if(!saveSettings()) - return; - interfaces->write(); - QDialog::accept(); -} - -/** - * 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() || firstDNSLineEdit->text().isEmpty())){ - QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "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()); - QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); - interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns); - interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); - } - - // IP Information - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); - return true; -} - -/** - * The Profile has changed. - * @profile the new profile. - */ -void InterfaceSetupImp::setProfile(const QString &profile){ - 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 set."); - 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 set."); - 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 interfacednsscript add", 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/net/networksetup/interfacesetupimp.h b/noncore/net/networksetup/interfacesetupimp.h deleted file mode 100644 index a0bec32..0000000 --- a/noncore/net/networksetup/interfacesetupimp.h +++ b/dev/null @@ -1,31 +0,0 @@ -#ifndef INTERFACESETUPIMP_H -#define INTERFACESETUPIMP_H - -#include "interfacesetup.h" - -class Interface; -class Interfaces; - -class InterfaceSetupImp : public InterfaceSetup { - Q_OBJECT - -public: - InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); - -protected slots: - void accept(); - -public slots: - void setProfile(const QString &profile); - -private: - bool saveSettings(); - Interfaces *interfaces; - Interface *interface; - -}; - -#endif - -// interfacesetupimp.h - diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index f9ca83b..b9fff56 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -4,17 +4,16 @@ #include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
#include "kprocess.h"
#include <qpushbutton.h>
-#include <qtabwidget.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
@@ -90,16 +89,17 @@ MainWindowImp::~MainWindowImp(){ delete iIt.key();
}
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
// I wonder why I can't delete the libraries
+ // What fucking shit this is.
//delete it.data();
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
@@ -216,59 +216,51 @@ void MainWindowImp::removeClicked(){ // 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 with a empty
- * tab. If tab is !NULL then append the interfaces setup widget to it.
+ * 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;
}
QString currentProfile = currentProfileLabel->text();
if(profilesList->count() <= 1 || currentProfile == "All"){
currentProfile = "";
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
i->getModuleOwner()->setProfile(currentProfile);
- QTabWidget *tabWidget = NULL;
- QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
+ QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
if(moduleConfigure != NULL){
- if(tabWidget != NULL){
- InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
- configure->setProfile(currentProfile);
- tabWidget->insertTab(configure, "TCP/IP");
- }
moduleConfigure->showMaximized();
moduleConfigure->show();
return;
}
}
- InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
- configure->setProfile(currentProfile);
+ InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose);
+ //configure->setProfile(currentProfile);
configure->showMaximized();
configure->show();
}
/**
* Pull up the information about the currently selected interface.
* Report an error if no interface is selected.
- * If the interface has a module owner then request its configure with a empty
- * tab. If tab is !NULL then append the interfaces setup widget to it.
+ * If the interface has a module owner then request its configure.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
@@ -279,29 +271,23 @@ void MainWindowImp::informationClicked(){ }
QStringList list;
for(uint i = 0; i < profilesList->count(); i++){
list.append(profilesList->text(i));
}
if(i->getModuleOwner()){
- QTabWidget *tabWidget = NULL;
- QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
+ QWidget *moduleInformation = i->getModuleOwner()->information(i);
if(moduleInformation != NULL){
- if(tabWidget != NULL){
- InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(information, "TCP/IP");
- }
moduleInformation->showMaximized();
moduleInformation->show();
return;
}
}
-
InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
information->showMaximized();
information->show();
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h index 96db5b3..92b125a 100644 --- a/noncore/net/networksetup/module.h +++ b/noncore/net/networksetup/module.h @@ -34,30 +34,28 @@ public: /** * Check to see if the interface i is owned by this module. * @param Interface* interface to check against * @return bool true if i is owned by this module, false otherwise. */ virtual bool isOwner(Interface *){ return false; }; /** - * Create, set tabWiget and return the WLANConfigure Module + * Create and return the WLANConfigure Module * @param Interface *i the interface to configure. - * @param tabWidget a pointer to the tab widget that this configure has. - * @return QWidget* pointer to the tab widget in this modules configure. + * @return QWidget* pointer to this modules configure. */ - virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; + virtual QWidget *configure(Interface *){ return NULL; } ; /** - * Create, set tabWiget and return the Information Module + * Create, and return the Information Module * @param Interface *i the interface to get info on. - * @param tabWidget a pointer to the tab widget that this information has. - * @return QWidget* pointer to the tab widget in this modules info. + * @return QWidget* pointer to this modules info. */ - virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; + virtual QWidget *information(Interface *){ return NULL; }; /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ virtual QList<Interface> getInterfaces() = 0; diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro index f09db93..9f28fbd 100644 --- a/noncore/net/networksetup/networksetup.pro +++ b/noncore/net/networksetup/networksetup.pro @@ -1,11 +1,11 @@ -DESTDIR = $(OPIEDIR)/bin +#DESTDIR = $(OPIEDIR)/bin TEMPLATE = app #CONFIG = qt warn_on debug CONFIG = qt warn_on release -HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h -SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -INTERFACES = mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui +HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h +SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp +INCLUDEPATH += $(OPIEDIR)/include interfaces/ +DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan +LIBS += -lqpe -Linterfaces -linterfaces +INTERFACES = mainwindow.ui addconnection.ui TARGET = networksetup diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index e545bd1..eb6fc42 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp @@ -11,37 +11,37 @@ #define PROCNETWIRELESS "/proc/net/wireless" #define IW_LOWER 0 #define IW_UPPER 256 /** * Constructor. Sets hasWirelessExtensions */ -WExtensions::WExtensions(QString interfaceName){ +WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){ interface = interfaceName; fd = socket( AF_INET, SOCK_DGRAM, 0 ); + if(fd == -1) + return; const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; - else - hasWirelessExtensions = false; } /** * @return QString the station name of the access point. */ QString WExtensions::station(){ if(!hasWirelessExtensions) return QString(); diff --git a/noncore/net/networksetup/wlan/wlan.pro b/noncore/net/networksetup/wlan/wlan.pro index f28feb2..23fc39a 100644 --- a/noncore/net/networksetup/wlan/wlan.pro +++ b/noncore/net/networksetup/wlan/wlan.pro @@ -1,12 +1,12 @@ TEMPLATE = lib CONFIG += qt warn_on release #CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/plugins/networksetup HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ +INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/ DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -L../interfaces/ -linterfaces INTERFACES = wlan.ui info.ui TARGET = wlanplugin VERSION = 1.0.0 diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 45952b9..7c902e0 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -10,20 +10,28 @@ #include <qdir.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qregexp.h> +#include <qpe/config.h> +#include <qtabwidget.h> +#include "interfacesetupimp.h" -WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ +WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ config = new Config("wireless"); + interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); + //configure->setProfile(currentProfile); + tabWidget->insertTab(interfaceSetup, "TCP/IP"); + readConfig(); + } WLANImp::~WLANImp( ){ delete config; } void WLANImp::readConfig() { @@ -104,19 +112,21 @@ bool WLANImp::writeConfig() return true; return writeWirelessOpts( ); } /** */ void WLANImp::accept() { - if ( writeConfig() ) + if ( writeConfig() ){ + interfaceSetup->saveChanges(); QDialog::accept(); } +} bool WLANImp::writeWirelessOpts( QString scheme ) { qWarning( "WLANImp::writeWirelessOpts entered." ); QString prev = "/etc/pcmcia/wireless.opts"; QFile prevFile(prev); if ( !prevFile.open( IO_ReadOnly ) ) return false; diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h index 59b7c59..608d681 100644 --- a/noncore/net/networksetup/wlan/wlanimp.h +++ b/noncore/net/networksetup/wlan/wlanimp.h @@ -1,27 +1,31 @@ #ifndef WLANIMP_H #define WLANIMP_H #include "wlan.h" -#include <qpe/config.h> +class InterfaceSetupImp; +class Interface; +class Config; class WLANImp : public WLAN { Q_OBJECT public: - WLANImp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); ~WLANImp( ); protected: void accept(); private: void readConfig(); bool writeConfig(); bool writeWirelessOpts( QString scheme = "*" ); bool writeWlanngOpts( QString scheme = "*" ); Config* config; + InterfaceSetupImp *interfaceSetup; + }; #endif diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index 9ab3b76..c8becb0 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp @@ -1,15 +1,17 @@ #include "wlanmodule.h" #include "wlanimp.h" #include "infoimp.h" #include "wextensions.h" +#include "interfaceinformationimp.h" #include <qlabel.h> #include <qprogressbar.h> +#include <qtabwidget.h> /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { } /** @@ -48,38 +50,36 @@ bool WLANModule::isOwner(Interface *i){ return false; i->setHardwareName("802.11b"); list.append(i); return true; } /** - * Create, set tabWiget and return the WLANConfigure Module - * @param tabWidget a pointer to the tab widget that this configure has. - * @return QWidget* pointer to the tab widget in this modules configure. + * Create, and return the WLANConfigure Module + * @return QWidget* pointer to this modules configure. */ -QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ - WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); - (*tabWidget) = wlanconfig->tabWidget; +QWidget *WLANModule::configure(Interface *i){ + WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); return wlanconfig; } /** - * Create, set tabWiget and return the Information Module - * @param tabWidget a pointer to the tab widget that this information has. - * @return QWidget* pointer to the tab widget in this modules info. + * Create, and return the Information Module + * @return QWidget* pointer to this modules info. */ -QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ +QWidget *WLANModule::information(Interface *i){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); - (*tabWidget) = info->tabWidget; + InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); + info->tabWidget->insertTab(information, "TCP/IP"); return info; } /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ diff --git a/noncore/net/networksetup/wlan/wlanmodule.h b/noncore/net/networksetup/wlan/wlanmodule.h index 1418ce8..a81ccff 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.h +++ b/noncore/net/networksetup/wlan/wlanmodule.h @@ -9,18 +9,18 @@ signals: void updateInterface(Interface *i); public: WLANModule(); ~WLANModule(); virtual void setProfile(QString newProfile); virtual bool isOwner(Interface *); - virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); - virtual QWidget *information(Interface *i, QTabWidget **tabWidget); + virtual QWidget *configure(Interface *i); + virtual QWidget *information(Interface *i); virtual QList<Interface> getInterfaces(); virtual void possibleNewInterfaces(QMap<QString, QString> &){}; virtual Interface *addNewInterface(QString name); virtual bool remove(Interface* i); virtual QString getPixmapName(Interface* i); private: QList<Interface> list; diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index d61c510..c83d909 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO @@ -1,8 +1,10 @@ +Make sure the C code in wextensions is clean. + WLAN needs to be re-written to not use Config WHERE Is DHCP info stored??? PPP module needs to be written Write a class that parses /proc and not ifconfig Possible other modules: ipsec, bluetooth, ipchains diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp deleted file mode 100644 index 929b3a1..0000000 --- a/noncore/settings/networksettings/interface.cpp +++ b/dev/null @@ -1,287 +0,0 @@ -#include "interface.h" -#include <qdatetime.h> -#include <qfile.h> -#include <qdir.h> -#include <qfileinfo.h> -#include <qtextstream.h> - -#define IFCONFIG "/sbin/ifconfig" -#define DHCP_INFO_DIR "/etc/dhcpc" - -#include <stdio.h> -#include <stdlib.h> - -Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ - refresh(); -} - -/** - * Set status - * @param newStatus - the new status - * emit updateInterface - */ -void Interface::setStatus(bool newStatus){ - if(status != newStatus){ - status = newStatus; - refresh(); - } -}; - -/** - * Set if attached or not (802.11 card pulled out for example) - * @param isAttached - if attached - * emit updateInterface - */ -void Interface::setAttached(bool isAttached){ - attached = isAttached; - emit(updateInterface(this)); -}; - -/** - * Set Hardware name - * @param name - the new name - * emit updateInterface - */ -void Interface::setHardwareName(QString name){ - hardwareName = name; - emit(updateInterface(this)); -}; - -/** - * Set Module owner - * @param owner - the new owner - * emit updateInterface - */ -void Interface::setModuleOwner(Module *owner){ - moduleOwner = owner; - emit(updateInterface(this)); -}; - - -/** - * Try to start the interface. - */ -void Interface::start(){ - // check to see if we are already running. - if(true == status) - return; - - int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); - // See if it was successfull... - if(ret != 0) - return; - - status = true; - refresh(); -} - -/** - * Try to stop the interface. - */ -void Interface::stop(){ - // check to see if we are already stopped. - if(false == status) - return; - - int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); - if(ret != 0) - return; - - status = true; - refresh(); -} - -/** - * Try to restart the interface. - */ -void Interface::restart(){ - stop(); - start(); -} - -/** - * Try to refresh the information about the interface. - * First call ifconfig, then check the dhcp-info file - * @return bool true if successfull. - */ -bool Interface::refresh(){ - // See if we are up. - if(status == false){ - macAddress = ""; - ip = "0.0.0.0"; - subnetMask = "0.0.0.0"; - broadcast = ""; - dhcp = false; - dhcpServerIp = ""; - leaseObtained = ""; - leaseExpires = ""; - emit(updateInterface(this)); - return true; - } - - 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()); - if(ret != 0){ - qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); - return false; - } - - QFile file(fileName); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); - return false; - } - - // Set to the defaults - macAddress = ""; - ip = "0.0.0.0"; - subnetMask = "0.0.0.0"; - broadcast = ""; - - QTextStream stream( &file ); - QString line; - while ( !stream.eof() ) { - line = stream.readLine(); - if(line.contains("HWaddr")){ - int mac = line.find("HWaddr"); - macAddress = line.mid(mac+7, line.length()); - } - if(line.contains("inet addr")){ - int ipl = line.find("inet addr"); - int space = line.find(" ", ipl+10); - ip = line.mid(ipl+10, space-ipl-10); - } - if(line.contains("Mask")){ - int mask = line.find("Mask"); - subnetMask = line.mid(mask+5, line.length()); - } - if(line.contains("Bcast")){ - int mask = line.find("Bcast"); - int space = line.find(" ", mask+6); - broadcast = line.mid(mask+6, space-mask-6); - } - } - file.close(); - QFile::remove(fileName); - - // DHCP TESTING - // reset DHCP info - dhcpServerIp = ""; - leaseObtained = ""; - leaseExpires = ""; - dhcp = false; - - QString dhcpDirectory(DHCP_INFO_DIR); - QDir d(dhcpDirectory); - if(!d.exists(dhcpDirectory)) - dhcpDirectory = "/var/run"; - - // See if we have - QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); - // If there is no DHCP information then exit now with no errors. - if(!QFile::exists(dhcpFile)){ - emit(updateInterface(this)); - return true; - } - - file.setName(dhcpFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); - return false; - } - - // leaseTime and renewalTime and used if pid and deamon exe can be accessed. - int leaseTime = 0; - int renewalTime = 0; - - stream.setDevice( &file ); - while ( !stream.eof() ) { - line = stream.readLine(); - if(line.contains("DHCPSIADDR=")) - dhcpServerIp = line.mid(11, line.length()); - if(line.contains("LEASETIME=")) - leaseTime = line.mid(10, line.length()).toInt(); - if(line.contains("RENEWALTIME=")) - renewalTime = line.mid(12, line.length()).toInt(); - } - file.close(); - //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); - //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); - - // Get the pid of the deamond - dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); - file.setName(dhcpFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); - return false; - } - - int pid = -1; - stream.setDevice( &file ); - while ( !stream.eof() ) { - line = stream.readLine(); - pid = line.toInt(); - } - file.close(); - - if( pid == -1){ - qDebug("Interface: Could not get pid of dhcpc deamon."); - return false; - } - - // Get the start running time of the deamon - fileName = (QString("/proc/%1/stat").arg(pid)); - file.setName(fileName); - stream.setDevice( &file ); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); - return false; - } - while ( !stream.eof() ) { - line = stream.readLine(); - } - file.close(); - long time = 0; - // Grab the start time - // pid com state ppid pgrp session tty_nr tpgid flags - sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " - // minflt cminflt majflt cmajflt utime stime cutime cstime priority - "%*u %*u %*u %*u %*u %*u %*d %*d %*d " - // nice 0 itrealvalue starttime - "%*d %*d %*d %lu", (long*) &time); - time = time/100; - - QDateTime datetime(QDateTime::currentDateTime()); - - // Get the uptime of the computer. - QFile f("/proc/uptime"); - if ( f.open(IO_ReadOnly) ) { // file opened successfully - QTextStream t( &f ); // use a text stream - int sec = 0; - t >> sec; - datetime = datetime.addSecs((-1*sec)); - f.close(); - } - else{ - qDebug("Interface: Can't open /proc/uptime to retrive uptime."); - return false; - } - - datetime = datetime.addSecs(time); - //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); - - // Calculate the start and renew times - leaseObtained = datetime.toString(); - - // Calculate the start and renew times - datetime = datetime.addSecs(leaseTime); - leaseExpires = datetime.toString(); - - dhcp = true; - - emit(updateInterface(this)); - return true; -} - -// interface.cpp - diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h deleted file mode 100644 index dc9c6d3..0000000 --- a/noncore/settings/networksettings/interface.h +++ b/dev/null @@ -1,71 +0,0 @@ -#ifndef INTERFACE_H -#define INTERFACE_H - -#include <qstring.h> -#include <qobject.h> - -class Module; - -class Interface : public QObject{ - Q_OBJECT - -signals: - void updateInterface(Interface *i); - -public: - Interface(QObject * parent=0, const char * name= "unknown", bool status = false); - virtual ~Interface(){}; - - virtual QString getInterfaceName(){ QString n(this->name()); return n; }; - - virtual bool getStatus(){ return status; }; - virtual void setStatus(bool newStatus); - - virtual bool isAttached(){ return attached; }; - virtual void setAttached(bool isAttached=false); - - virtual QString getHardwareName(){ return hardwareName; }; - virtual void setHardwareName(QString name="Unknown"); - - virtual Module* getModuleOwner(){ return moduleOwner; }; - virtual void setModuleOwner(Module *owner=NULL); - - // inet information. - QString getMacAddress(){ return macAddress; }; - QString getIp(){ return ip; }; - QString getSubnetMask(){ return subnetMask; }; - QString getBroadcast(){ return broadcast; }; - bool isDhcp(){ return dhcp; }; - QString getDhcpServerIp(){ return dhcpServerIp; }; - QString getLeaseObtained(){ return leaseObtained; }; - QString getLeaseExpires(){ return leaseExpires; }; - -public slots: - bool refresh(); - void start(); - void stop(); - void restart(); - -private: - // Interface information - bool status; - bool attached; - QString hardwareName; - Module *moduleOwner; - - // Network information - QString macAddress; - QString ip; - QString broadcast; - QString subnetMask; - bool dhcp; - QString dhcpServerIp; - QString leaseObtained; - QString leaseExpires; - -}; - -#endif - -// interface.h - diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui deleted file mode 100644 index 0ec67c2..0000000 --- a/noncore/settings/networksettings/interfaceadvanced.ui +++ b/dev/null @@ -1,344 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceAdvanced</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>InterfaceAdvanced</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>214</width> - <height>286</height> - </rect> - </property> - <property stdset="1"> - <name>maximumSize</name> - <size> - <width>240</width> - <height>32767</height> - </size> - </property> - <property stdset="1"> - <name>caption</name> - <string>Advanced Interface Information</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>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>MAC Address</string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>interfaceName</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>eth0</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>macAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>00:00:00:00:00:00</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel7</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Interface</string> - </property> - </widget> - <widget row="4" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>true</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>Subnet Mask</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>ipAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="4" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>subnetMaskLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Broadcast</string> - </property> - </widget> - <widget row="3" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>broadcastLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>QGroupBox</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpInformation</cstring> - </property> - <property stdset="1"> - <name>title</name> - <string>DHCP Information</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="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel6</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>DHCP Server</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseExpiresLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>leaseObtainedLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel9</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Lease Expires</string> - </property> - </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel8</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Lease Obtained</string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>dhcpServerLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - </grid> - </widget> - <spacer row="6" column="1" > - <property> - <name>name</name> - <cstring>Spacer2</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> - </grid> -</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> -</UI> diff --git a/noncore/settings/networksettings/interfaceedit.cpp b/noncore/settings/networksettings/interfaceedit.cpp deleted file mode 100644 index 25599ef..0000000 --- a/noncore/settings/networksettings/interfaceedit.cpp +++ b/dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'interfaceedit.ui' -** -** Created: Mon Sep 23 12:18:55 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#include "interfaceedit.h" - -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qframe.h> -#include <qgroupbox.h> -#include <qlabel.h> -#include <qlineedit.h> -#include <qpushbutton.h> -#include <qspinbox.h> -#include "qwidget.h" -#include <qlayout.h> -#include <qvariant.h> -#include <qtooltip.h> -#include <qwhatsthis.h> - -/* - * Constructs a InterfaceConfiguration which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - */ -InterfaceConfiguration::InterfaceConfiguration( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) -{ - if ( !name ) - setName( "InterfaceConfiguration" ); - resize( 177, 306 ); - setCaption( tr( "Interface Configuration" ) ); - InterfaceConfigurationLayout = new QGridLayout( this ); - InterfaceConfigurationLayout->setSpacing( 6 ); - InterfaceConfigurationLayout->setMargin( 11 ); - - profile = new QComboBox( FALSE, this, "profile" ); - profile->insertItem( tr( "All" ) ); - - InterfaceConfigurationLayout->addWidget( profile, 2, 1 ); - - TextLabel1 = new QLabel( this, "TextLabel1" ); - TextLabel1->setText( tr( "Profile:" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel1, 2, 0 ); - - Line1 = new QFrame( this, "Line1" ); - Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - - InterfaceConfigurationLayout->addMultiCellWidget( Line1, 1, 1, 0, 1 ); - - CheckBox3 = new QCheckBox( this, "CheckBox3" ); - CheckBox3->setText( tr( "Automaticly bring up" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( CheckBox3, 0, 0, 0, 1 ); - - dhcpCheckBox = new QCheckBox( this, "dhcpCheckBox" ); - dhcpCheckBox->setText( tr( "DHCP" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( dhcpCheckBox, 3, 3, 0, 1 ); - - TextLabel3_3_2 = new QLabel( this, "TextLabel3_3_2" ); - TextLabel3_3_2->setText( tr( "Lease Hours" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel3_3_2, 4, 0 ); - - SpinBox1_2 = new QSpinBox( this, "SpinBox1_2" ); - SpinBox1_2->setMaxValue( 336 ); - SpinBox1_2->setMinValue( 1 ); - SpinBox1_2->setValue( 24 ); - - InterfaceConfigurationLayout->addWidget( SpinBox1_2, 4, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); - InterfaceConfigurationLayout->addItem( spacer, 11, 1 ); - - TextLabel4 = new QLabel( this, "TextLabel4" ); - TextLabel4->setText( tr( "IP Address" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel4, 6, 0 ); - - ipAddressEdit = new QLineEdit( this, "ipAddressEdit" ); - - InterfaceConfigurationLayout->addWidget( ipAddressEdit, 6, 1 ); - - TextLabel5 = new QLabel( this, "TextLabel5" ); - TextLabel5->setText( tr( "Subnet Mask" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel5, 7, 0 ); - - firstDNSLineEdit = new QLineEdit( this, "firstDNSLineEdit" ); - - InterfaceConfigurationLayout->addWidget( firstDNSLineEdit, 9, 1 ); - - TextLabel3 = new QLabel( this, "TextLabel3" ); - TextLabel3->setText( tr( "Second DNS" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel3, 10, 0 ); - - subnetMaskEdit = new QLineEdit( this, "subnetMaskEdit" ); - - InterfaceConfigurationLayout->addWidget( subnetMaskEdit, 7, 1 ); - - gatewayEdit = new QLineEdit( this, "gatewayEdit" ); - - InterfaceConfigurationLayout->addWidget( gatewayEdit, 8, 1 ); - - TextLabel7 = new QLabel( this, "TextLabel7" ); - TextLabel7->setText( tr( "Gateway" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel7, 8, 0 ); - - TextLabel2 = new QLabel( this, "TextLabel2" ); - TextLabel2->setText( tr( "First DNS" ) ); - - InterfaceConfigurationLayout->addWidget( TextLabel2, 9, 0 ); - - secondDNSLineEdit = new QLineEdit( this, "secondDNSLineEdit" ); - - InterfaceConfigurationLayout->addWidget( secondDNSLineEdit, 10, 1 ); - - GroupBox2 = new QGroupBox( this, "GroupBox2" ); - GroupBox2->setTitle( tr( "Static Ip Configuration" ) ); - - InterfaceConfigurationLayout->addMultiCellWidget( GroupBox2, 5, 5, 0, 1 ); - - // signals and slots connections - connect( dhcpCheckBox, SIGNAL( toggled(bool) ), SpinBox1_2, SLOT( setEnabled(bool) ) ); - connect( dhcpCheckBox, SIGNAL( toggled(bool) ), GroupBox2, SLOT( setDisabled(bool) ) ); -} - -/* - * Destroys the object and frees any allocated resources - */ -InterfaceConfiguration::~InterfaceConfiguration() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/noncore/settings/networksettings/interfaceedit.h b/noncore/settings/networksettings/interfaceedit.h deleted file mode 100644 index a65c030..0000000 --- a/noncore/settings/networksettings/interfaceedit.h +++ b/dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'interfaceedit.ui' -** -** Created: Mon Sep 23 12:18:55 2002 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#ifndef INTERFACECONFIGURATION_H -#define INTERFACECONFIGURATION_H - -#include <qvariant.h> -#include <qwidget.h> -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QCheckBox; -class QComboBox; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QSpinBox; - -class InterfaceConfiguration : public QWidget -{ - Q_OBJECT - -public: - InterfaceConfiguration( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); - ~InterfaceConfiguration(); - - QComboBox* profile; - QLabel* TextLabel1; - QFrame* Line1; - QCheckBox* CheckBox3; - QCheckBox* dhcpCheckBox; - QLabel* TextLabel3_3_2; - QSpinBox* SpinBox1_2; - QLabel* TextLabel4; - QLineEdit* ipAddressEdit; - QLabel* TextLabel5; - QLineEdit* firstDNSLineEdit; - QLabel* TextLabel3; - QLineEdit* subnetMaskEdit; - QLineEdit* gatewayEdit; - QLabel* TextLabel7; - QLabel* TextLabel2; - QLineEdit* secondDNSLineEdit; - QGroupBox* GroupBox2; - -protected: - QGridLayout* InterfaceConfigurationLayout; -}; - -#endif // INTERFACECONFIGURATION_H diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui deleted file mode 100644 index 2838d19..0000000 --- a/noncore/settings/networksettings/interfaceinformation.ui +++ b/dev/null @@ -1,343 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceInformation</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>InterfaceInformation</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>219</width> - <height>255</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Interface Information</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="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" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel22</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="1" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel23</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Subnet Mask</string> - </property> - </widget> - <widget row="2" column="0" > - <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 row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel24</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>MShape</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>MShadow</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>Broadcast</string> - </property> - </widget> - <widget row="1" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>subnetMaskLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <widget row="2" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>macAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>00:00:00:00:00:00</string> - </property> - </widget> - <widget row="3" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>broadcastLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string></string> - </property> - </widget> - <widget row="0" column="1" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>ipAddressLabel</cstring> - </property> - <property stdset="1"> - <name>frameShape</name> - <enum>Panel</enum> - </property> - <property stdset="1"> - <name>frameShadow</name> - <enum>Sunken</enum> - </property> - <property stdset="1"> - <name>text</name> - <string>0.0.0.0</string> - </property> - </widget> - <spacer row="7" column="1" > - <property> - <name>name</name> - <cstring>Spacer18</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> - <widget row="6" column="0" rowspan="1" colspan="2" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout2</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <spacer> - <property> - <name>name</name> - <cstring>Spacer10</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</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>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>advancedButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>View &Advanced Information</string> - </property> - </widget> - </hbox> - </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>Line5</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - </grid> -</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> -<tabstops> - <tabstop>startButton</tabstop> - <tabstop>stopButton</tabstop> - <tabstop>refreshButton</tabstop> - <tabstop>restartButton</tabstop> - <tabstop>advancedButton</tabstop> -</tabstops> -</UI> diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp deleted file mode 100644 index 43483fb..0000000 --- a/noncore/settings/networksettings/interfaceinformationimp.cpp +++ b/dev/null @@ -1,70 +0,0 @@ -#include "interfaceinformationimp.h" -#include "interfaceadvanced.h" - -#include <qpushbutton.h> -#include <qlabel.h> -#include <qgroupbox.h> -#include <assert.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){ - assert(i); - - interface = i; - connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); - 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){ - 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(); -} - -// infoimp.cpp - diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h deleted file mode 100644 index 42213cc..0000000 --- a/noncore/settings/networksettings/interfaceinformationimp.h +++ b/dev/null @@ -1,27 +0,0 @@ -#ifndef INTERFACEINFORMATIONIMP_H -#define INTERFACEINFORMATIONIMP_H - -#include "interfaceinformation.h" -#include "interface.h" - -class InterfaceInformationImp : public InterfaceInformation { - -Q_OBJECT - -public: - InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); - ~InterfaceInformationImp(){}; - -private slots: - void advanced(); - void updateInterface(Interface *i); - -private: - Interface *interface; - -}; - -#endif - -// addserviceimp.h - diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp deleted file mode 100644 index 377a6db..0000000 --- a/noncore/settings/networksettings/interfaces.cpp +++ b/dev/null @@ -1,638 +0,0 @@ -#include "interfaces.h" - -#include <qfile.h> -#include <qtextstream.h> -#include <qregexp.h> - -#define AUTO "auto" -#define IFACE "iface" -#define MAPPING "mapping" - -/** - * Constructor. Reads in the interfaces file and then split the file up by - * the \n for interfaces variable. - * @param useInterfacesFile if an interface file other then the default is - * desired to be used it should be passed in. - */ -Interfaces::Interfaces(QString useInterfacesFile){ - acceptedFamily.append(INTERFACES_FAMILY_INET); - acceptedFamily.append(INTERFACES_FAMILY_IPX); - acceptedFamily.append(INTERFACES_FAMILY_INET6); - - interfacesFile = useInterfacesFile; - QFile file(interfacesFile); - if (!file.open(IO_ReadOnly)){ - qDebug(QString("Interfaces: Can't open file: %1 for reading.").arg(interfacesFile).latin1()); - currentIface = interfaces.end(); - currentMapping = interfaces.end(); - return; - } - QTextStream stream( &file ); - QString line; - while ( !stream.eof() ) { - line += stream.readLine(); - line += "\n"; - } - file.close(); - interfaces = QStringList::split("\n", line, true); - - currentIface = interfaces.end(); - currentMapping = interfaces.end(); -} - - -/** - * Get a list of all interfaces in the interface file. Usefull for - * hardware that is not currently connected such as an 802.11b card - * not plugged in, but configured for when it is plugged in. - * @return Return string list of interfaces. - **/ -QStringList Interfaces::getInterfaceList(){ - QStringList list; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - if(line.contains(IFACE) && line.at(0) != '#'){ - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace >= 0){ - line = line.mid(0, findSpace); - list.append(line); - } - } - } - return list; -} - -/** - * Find out if interface is in an "auto" group or not. - * Report any duplicates such as eth0 being in two differnt auto's - * @param interface interface to check to see if it is on or not. - * @return true is interface is in auto - */ -bool Interfaces::isAuto(QString interface){ - QStringList autoLines = interfaces.grep(QRegExp(AUTO)); - QStringList awi = autoLines.grep(QRegExp(interface)); - if(awi.count() > 1) - qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); - if(awi.count() < 1) - return false; - return true; -} - -/** - * Attempt to set the auto option for interface to setAuto. - * @param interface the interface to set - * @param setAuto the value to set interface to. - * @return false if already set to setAuto. - * */ -bool Interfaces::setAuto(QString interface, bool setAuto){ - // Don't need to set it if it is already set. - if(isAuto(interface) == setAuto) - return false; - - bool changed = false; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - if((*it).contains(AUTO)){ - //We know that they are not in any group so let add to this auto. - if(setAuto){ - (*it) = (*it) += " " + interface; - // Don't care to have such thins as: auto eth0 lo usb0 - (*it) = (*it).simplifyWhiteSpace(); - changed = true; - break; - } - else{ - if((*it).contains(interface)){ - (*it) = (*it).replace(QRegExp(interface), ""); - // clean up - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line == AUTO) - (*it) = ""; - changed = true; - // Don't break because we want to make sure we remove all cases. - } - } - } - } - if(changed == false){ - if(setAuto == true) - interfaces.append(QString(AUTO" %1").arg(interface)); - else{ - qDebug(QString("Interfaces: Can't set interface %1 auto to false sense it is already false.").arg(interface).latin1()); - } - } - return true; -} - -/** - * Set the current interface to interface. This needs to be done before you - * can call getFamily(), getMethod, and get/setOption(). - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @return bool true if it is successfull. - */ -bool Interfaces::setInterface(QString interface){ - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - return setStanza(IFACE, interface, currentIface); -} - -/** - * A quick helper funtion to see if the current interface is set. - * @return bool true if set, false otherwise. - */ -bool Interfaces::isInterfaceSet(){ - return (currentIface != interfaces.end()); -} - -/** - * Add a new interface of with the settings - family and method - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @param family the family of this interface inet or inet, ipx or inet6 - * Must of one of the families defined in interfaces.h - * @param method for the family. see interfaces man page for family methods. - * @return true if successfull. - */ -bool Interfaces::addInterface(QString interface, QString family, QString method){ - if(acceptedFamily.contains(family)==0) - return false; - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - interfaces.append(""); - interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); - return true; -} - -/** - * Copies interface with name interface to name newInterface - * @param newInterface name of the new interface. - * @return bool true if successfull - */ -bool Interfaces::copyInterface(QString interface, QString newInterface){ - if(!setInterface(interface)) return false; - - QStringList::Iterator it = currentIface; - it++; - - bool error; - addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); - if(!setInterface(newInterface)) return false; - QStringList::Iterator newIface = currentIface; - newIface++; - - for ( it; it != interfaces.end(); ++it ){ - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) - break; - newIface = interfaces.insert(newIface, *it); - } - - return true; -} - -/** - * Remove the currently selected interface and all of its options. - * @return bool if successfull or not. - */ -bool Interfaces::removeInterface(){ - if(currentIface == interfaces.end()) - return false; - (*currentIface) = ""; - return removeAllInterfaceOptions(); -} - -/** - * Gets the hardware name of the interface that is currently selected. - * @return QString name of the hardware interface (eth0, usb2, wlan1...). - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceName(bool &error){ - if(currentIface == interfaces.end()){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace < 0){ - error = true; - return QString(); - } - error = false; - return line.mid(0, findSpace); -} - -/** - * Gets the family name of the interface that is currently selected. - * @return QString name of the family (inet, inet6, ipx). - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceFamily(bool &error){ - QString name = getInterfaceName(error); - if(error){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length() +1, line.length()); - line = line.mid(name.length()+1, line.length()); - line = line.simplifyWhiteSpace(); - int findSpace = line.find(" "); - if( findSpace < 0){ - error = true; - return QString(); - } - error = false; - return line.mid(0, findSpace); -} - -/** - * Gets the method of the interface that is currently selected. - * @return QString name of the method such as staic or dhcp. - * See the man page of interfaces for possible methods depending on the family. - * @param error set to true if any error occurs, false otherwise. - */ -QString Interfaces::getInterfaceMethod(bool &error){ - QString name = getInterfaceName(error); - if(error){ - error = true; - return QString(); - } - QString family = getInterfaceFamily(error); - if(error){ - error = true; - return QString(); - } - QString line = (*currentIface); - line = line.mid(QString(IFACE).length()+1, line.length()); - line = line.mid(name.length()+1, line.length()); - line = line.mid(family.length()+1, line.length()); - line = line.simplifyWhiteSpace(); - error = false; - return line; -} - -/** - * Sets the interface name to newName. - * @param newName the new name of the interface. All whitespace is removed. - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceName(QString newName){ - if(currentIface == interfaces.end()) - return false; - newName = newName.simplifyWhiteSpace(); - newName = newName.replace(QRegExp(" "), ""); - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); - return !returnValue; -} - -/** - * Sets the interface family to newName. - * @param newName the new name of the interface. Must be one of the families - * defined in the interfaces.h file. - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceFamily(QString newName){ - if(currentIface == interfaces.end()) - return false; - if(acceptedFamily.contains(newName)==0) - return false; - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); - return !returnValue; -} - -/** - * Sets the interface method to newName - * @param newName the new name of the interface - * @return bool true if successfull. - */ -bool Interfaces::setInterfaceMethod(QString newName){ - if(currentIface == interfaces.end()) - return false; - bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); - return !returnValue; -} - -/** - * Get a value for an option in the currently selected interface. For example - * calling getInterfaceOption("address") on the following stanza would - * return 192.168.1.1. - * iface eth0 static - * address 192.168.1.1 - * @param option the options to get the value. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -QString Interfaces::getInterfaceOption(QString option, bool &error){ - return getOption(currentIface, option, error); -} - -/** - * Set a value for an option in the currently selected interface. If option - * doesn't exist then it is added along with the value. - * @param option the options to set the value. - * @param value the value that option should be set to. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -bool Interfaces::setInterfaceOption(QString option, QString value){ - return setOption(currentIface, option, value); -} - -/** - * Removes a value for an option in the currently selected interface. - * @param option the options to set the value. - * @param value the value that option should be set to. - * @param error set to true if any error occurs, false otherwise. - * @return QString the options value. QString::null if error == true - */ -bool Interfaces::removeInterfaceOption(QString option, QString value){ - return removeOption(currentIface, option, value); -} - -/** - * Removes all of the options from the currently selected interface. - * @return bool error if if successfull - */ -bool Interfaces::removeAllInterfaceOptions(){ - return removeAllOptions(currentIface); -} - -/** - * Set the current map to interface's map. This needs to be done before you - * can call addMapping(), set/getMap(), and get/setScript(). - * @param interface the name of the interface to set. All whitespace is - * removed from the interface name. - * @return bool true if it is successfull. - */ -bool Interfaces::setMapping(QString interface){ - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - return setStanza(MAPPING, interface, currentMapping); -} - -/** - * Adds a new Mapping to the interfaces file with interfaces. - * @param interface the name(s) of the interfaces to set to this mapping - */ -void Interfaces::addMapping(QString option){ - interfaces.append(""); - interfaces.append(QString(MAPPING " %1").arg(option)); -} - -/** - * Remove the currently selected map and all of its options. - * @return bool if successfull or not. - */ -bool Interfaces::removeMapping(){ - if(currentMapping == interfaces.end()) - return false; - (*currentMapping) = ""; - return removeAllOptions(currentMapping); -} - -/** - * Set a map option within a mapping. - * @param map map to use - * @param value value to go with map - * @return bool true if it is successfull. - */ -bool Interfaces::setMap(QString map, QString value){ - return setOption(currentMapping, map, value); -} - -/** - * Removes a map option within a mapping. - * @param map map to use - * @param value value to go with map - * @return bool true if it is successfull. - */ -bool Interfaces::removeMap(QString map, QString value){ - return removeOption(currentMapping, map, value); -} - -/** - * Get a map value within a mapping. - * @param map map to get value of - * @param bool true if it is successfull. - * @return value that goes to the map - */ -QString Interfaces::getMap(QString map, bool &error){ - return getOption(currentMapping, map, error); -} - -/** - * Sets a script value of the current mapping to argument. - * @param argument the script name. - * @return true if successfull. - */ -bool Interfaces::setScript(QString argument){ - return setOption(currentMapping, "script", argument); -} - -/** - * @param error true if could not retrieve the current script argument. - * @return QString the argument of the script for the current mapping. - */ -QString Interfaces::getScript(bool &error){ - return getOption(currentMapping, "script", error); -} - -/** - * Helper function used to parse through the QStringList and put pointers in - * the correct place. - * @param stanza The stanza (auto, iface, mapping) to look for. - * @param option string that must be in the stanza's main line. - * @param interator interator to place at location of stanza if successfull. - * @return bool true if the stanza is found. - */ -bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ - bool found = false; - iterator = interfaces.end(); - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ - uint point = line.find(option); - bool valid = true; - if(point > 0){ - // There are more chars in the line. check +1 - if(line.at(point-1) != ' ') - valid = false; - } - point += option.length(); - if(point < line.length()-1){ - // There are more chars in the line. check -1 - if(line.at(point) != ' ') - valid = false; - } - if(valid){ - if(found == true){ - qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); - } - found = true; - iterator = it; - } - } - } - return found; -} - -/** - * Sets a value of an option in a stanza - * @param start the start of the stanza - * @param option the option to use when setting value. - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ - if(start == interfaces.end()) - return false; - - bool found = false; - 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; - } - if((*it).contains(option) && it != start && (*it).at(0) != '#'){ - // Found it in stanza so replace it. - if(found) - qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); - found = true; - (*it) = QString("\t%1 %2").arg(option).arg(value); - } - } - if(!found){ - QStringList::Iterator p = start; - interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); - found = true; - } - return found; -} -/** - * Removes a option in a stanza - * @param start the start of the stanza - * @param option the option to use when setting value. - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ - if(start == interfaces.end()) - return false; - - bool found = false; - for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - // got to the end without finding it - break; - } - if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ - // Found it in stanza so replace it. - if(found) - qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); - found = true; - (*it) = ""; - } - } - return found; -} - -/** - * Removes all options in a stanza - * @param start the start of the stanza - * @return bool true if successfull, false otherwise. - */ -bool Interfaces::removeAllOptions(QStringList::Iterator start){ - if(start == interfaces.end()) - return false; - - QStringList::Iterator it = start; - it = ++it; - for (it; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - break; - } - it = interfaces.remove(it); - it = --it; - } - // Leave a space between this interface and the next. - interfaces.insert(it, QString("")); - return true; -} - -/** - * Gets a value of an option in a stanza - * @param start the start of the stanza - * @param option the option to use when getting the value. - * @param bool true if errors false otherwise. - * @return QString the value of option QString::null() if error == true. - */ -QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ - if(start == interfaces.end()){ - error = false; - return QString(); - } - - QString value; - bool found = false; - for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { - if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ - break; - } - if((*it).contains(option) && (*it).at(0) != '#'){ - if(found) - qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); - found = true; - QString line = (*it).simplifyWhiteSpace(); - int space = line.find(" ", option.length()); - if(space != -1) - value = line.mid(space+1, line.length()); - else - qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); - } - } - error = !found; - return value; -} - -/** - * Write out the interfaces file to the file passed into the constructor. - * Removes any excess blank lines over 1 line long. - * @return bool true if successfull, false if not. - */ -bool Interfaces::write(){ - QFile::remove(interfacesFile); - QFile file(interfacesFile); - - if (!file.open(IO_ReadWrite)){ - qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); - return false; - } - QTextStream stream( &file ); - int whiteSpaceCount = 0; - for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { - QString line = (*it).simplifyWhiteSpace(); - line = line.replace(QRegExp(" "),""); - if(line.length() == 0) - whiteSpaceCount++; - else - whiteSpaceCount = 0; - if(whiteSpaceCount < 2){ - qDebug((*it).latin1()); - stream << (*it) << '\n'; - } - } - file.close(); - return true; -} - -// interfaces.cpp - diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h deleted file mode 100644 index e09ea71..0000000 --- a/noncore/settings/networksettings/interfaces.h +++ b/dev/null @@ -1,76 +0,0 @@ -#ifndef INTERFACES_H -#define INTERFACES_H - -#include <qstring.h> -#include <qstringlist.h> - -#define INTERFACES_LOOPBACK "loopback" - -#define INTERFACES_FAMILY_INET "inet" -#define INTERFACES_FAMILY_IPX "ipx" -#define INTERFACES_FAMILY_INET6 "inet6" - -#define INTERFACES_METHOD_DHCP "dhcp" -#define INTERFACES_METHOD_STATIC "static" -#define INTERFACES_METHOD_PPP "ppp" - -/** - * This class provides a clean frontend for parsing the network interfaces file. - * It provides helper functions to minipulate the options within the file. - * See the interfaces man page for the syntax rules. - */ -class Interfaces { - -public: - Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); - QStringList getInterfaceList(); - - bool isAuto(QString interface); - bool setAuto(QString interface, bool setAuto); - - bool removeInterface(); - bool addInterface(QString interface, QString family, QString method); - bool copyInterface(QString oldInterface, QString newInterface); - bool setInterface(QString interface); - bool isInterfaceSet(); - QString getInterfaceName(bool &error); - bool setInterfaceName(QString newName); - QString getInterfaceFamily(bool &error); - bool setInterfaceFamily(QString newName); - QString getInterfaceMethod(bool &error); - bool setInterfaceMethod(QString newName); - QString getInterfaceOption(QString option, bool &error); - bool setInterfaceOption(QString option, QString value); - bool removeInterfaceOption(QString option, QString value); - bool removeAllInterfaceOptions(); - - bool setMapping(QString interface); - bool removeMapping(); - void addMapping(QString options); - bool setMap(QString map, QString value); - bool removeMap(QString map, QString value); - QString getMap(QString map, bool &error); - bool setScript(QString); - QString getScript(bool &error); - - bool write(); - -private: - bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); - bool setOption(QStringList::Iterator start, QString option, QString value); - bool removeOption(QStringList::Iterator start, QString option, QString value); - QString getOption(QStringList::Iterator start, QString option, bool &error); - bool removeAllOptions(QStringList::Iterator start); - - QString interfacesFile; - QStringList interfaces; - QStringList::Iterator currentIface; - QStringList::Iterator currentMapping; - - QStringList acceptedFamily; -}; - -#endif - -// interfaces - diff --git a/noncore/settings/networksettings/interfacesetup.ui b/noncore/settings/networksettings/interfacesetup.ui deleted file mode 100644 index 0c834fe..0000000 --- a/noncore/settings/networksettings/interfacesetup.ui +++ b/dev/null @@ -1,284 +0,0 @@ -<!DOCTYPE UI><UI> -<class>InterfaceSetup</class> -<widget> - <class>QDialog</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> - <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> - <property stdset="1"> - <name>name</name> - <cstring>Layout9</cstring> - </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>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> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>First DNS</string> - </property> - </widget> - <widget row="0" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel4</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>IP Address</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1_2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Gateway</string> - </property> - </widget> - <widget row="4" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel3</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Second DNS</string> - </property> - </widget> - <widget row="3" column="1" > - <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> -<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/interfacesetupimp.cpp b/noncore/settings/networksettings/interfacesetupimp.cpp deleted file mode 100644 index a8731a9..0000000 --- a/noncore/settings/networksettings/interfacesetupimp.cpp +++ b/dev/null @@ -1,147 +0,0 @@ -#include "interfacesetupimp.h" -#include "interface.h" -#include "interfaces.h" - -#include <qcombobox.h> -#include <qcheckbox.h> -#include <qlineedit.h> -#include <qspinbox.h> -#include <qgroupbox.h> -#include <qlabel.h> - -#include <qmessagebox.h> - -#include <assert.h> - -#define DNSSCRIPT "interfacednsscript" - -/** - * Constuctor. Set up the connection and load the first profile. - */ -InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : InterfaceSetup(parent, name, modal, fl){ - assert(i); - interface = i; - interfaces = new Interfaces(); - bool error = false; - if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ - staticGroupBox->hide(); - dhcpCheckBox->hide(); - leaseTime->hide(); - leaseHoursLabel->hide(); - } -} - -/** - * Save the current settings, then write out the interfaces file and close. - */ -void InterfaceSetupImp::accept(){ - if(!saveSettings()) - return; - interfaces->write(); - QDialog::accept(); -} - -/** - * 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() || firstDNSLineEdit->text().isEmpty())){ - QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "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()); - QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); - interfaces->setInterfaceOption("up "DNSSCRIPT" add ", dns); - interfaces->setInterfaceOption("down "DNSSCRIPT" remove ", dns); - } - - // IP Information - interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); - return true; -} - -/** - * The Profile has changed. - * @profile the new profile. - */ -void InterfaceSetupImp::setProfile(const QString &profile){ - 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 set."); - 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 set."); - 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 interfacednsscript add", 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/interfacesetupimp.h b/noncore/settings/networksettings/interfacesetupimp.h deleted file mode 100644 index a0bec32..0000000 --- a/noncore/settings/networksettings/interfacesetupimp.h +++ b/dev/null @@ -1,31 +0,0 @@ -#ifndef INTERFACESETUPIMP_H -#define INTERFACESETUPIMP_H - -#include "interfacesetup.h" - -class Interface; -class Interfaces; - -class InterfaceSetupImp : public InterfaceSetup { - Q_OBJECT - -public: - InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0); - -protected slots: - void accept(); - -public slots: - void setProfile(const QString &profile); - -private: - bool saveSettings(); - Interfaces *interfaces; - Interface *interface; - -}; - -#endif - -// interfacesetupimp.h - diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index f9ca83b..b9fff56 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -4,17 +4,16 @@ #include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
#include "kprocess.h"
#include <qpushbutton.h>
-#include <qtabwidget.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
@@ -90,16 +89,17 @@ MainWindowImp::~MainWindowImp(){ delete iIt.key();
}
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
// I wonder why I can't delete the libraries
+ // What fucking shit this is.
//delete it.data();
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
@@ -216,59 +216,51 @@ void MainWindowImp::removeClicked(){ // 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 with a empty
- * tab. If tab is !NULL then append the interfaces setup widget to it.
+ * 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;
}
QString currentProfile = currentProfileLabel->text();
if(profilesList->count() <= 1 || currentProfile == "All"){
currentProfile = "";
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
i->getModuleOwner()->setProfile(currentProfile);
- QTabWidget *tabWidget = NULL;
- QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget);
+ QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
if(moduleConfigure != NULL){
- if(tabWidget != NULL){
- InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
- configure->setProfile(currentProfile);
- tabWidget->insertTab(configure, "TCP/IP");
- }
moduleConfigure->showMaximized();
moduleConfigure->show();
return;
}
}
- InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, false, Qt::WDestructiveClose);
- configure->setProfile(currentProfile);
+ InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose);
+ //configure->setProfile(currentProfile);
configure->showMaximized();
configure->show();
}
/**
* Pull up the information about the currently selected interface.
* Report an error if no interface is selected.
- * If the interface has a module owner then request its configure with a empty
- * tab. If tab is !NULL then append the interfaces setup widget to it.
+ * If the interface has a module owner then request its configure.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
@@ -279,29 +271,23 @@ void MainWindowImp::informationClicked(){ }
QStringList list;
for(uint i = 0; i < profilesList->count(); i++){
list.append(profilesList->text(i));
}
if(i->getModuleOwner()){
- QTabWidget *tabWidget = NULL;
- QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget);
+ QWidget *moduleInformation = i->getModuleOwner()->information(i);
if(moduleInformation != NULL){
- if(tabWidget != NULL){
- InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(information, "TCP/IP");
- }
moduleInformation->showMaximized();
moduleInformation->show();
return;
}
}
-
InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true);
information->showMaximized();
information->show();
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h index 96db5b3..92b125a 100644 --- a/noncore/settings/networksettings/module.h +++ b/noncore/settings/networksettings/module.h @@ -34,30 +34,28 @@ public: /** * Check to see if the interface i is owned by this module. * @param Interface* interface to check against * @return bool true if i is owned by this module, false otherwise. */ virtual bool isOwner(Interface *){ return false; }; /** - * Create, set tabWiget and return the WLANConfigure Module + * Create and return the WLANConfigure Module * @param Interface *i the interface to configure. - * @param tabWidget a pointer to the tab widget that this configure has. - * @return QWidget* pointer to the tab widget in this modules configure. + * @return QWidget* pointer to this modules configure. */ - virtual QWidget *configure(Interface *, QTabWidget **){ return NULL; } ; + virtual QWidget *configure(Interface *){ return NULL; } ; /** - * Create, set tabWiget and return the Information Module + * Create, and return the Information Module * @param Interface *i the interface to get info on. - * @param tabWidget a pointer to the tab widget that this information has. - * @return QWidget* pointer to the tab widget in this modules info. + * @return QWidget* pointer to this modules info. */ - virtual QWidget *information(Interface *, QTabWidget **){ return NULL; }; + virtual QWidget *information(Interface *){ return NULL; }; /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ virtual QList<Interface> getInterfaces() = 0; diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro index f09db93..9f28fbd 100644 --- a/noncore/settings/networksettings/networksetup.pro +++ b/noncore/settings/networksettings/networksetup.pro @@ -1,11 +1,11 @@ -DESTDIR = $(OPIEDIR)/bin +#DESTDIR = $(OPIEDIR)/bin TEMPLATE = app #CONFIG = qt warn_on debug CONFIG = qt warn_on release -HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h -SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -INTERFACES = mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui +HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h +SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp +INCLUDEPATH += $(OPIEDIR)/include interfaces/ +DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan +LIBS += -lqpe -Linterfaces -linterfaces +INTERFACES = mainwindow.ui addconnection.ui TARGET = networksetup diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index e545bd1..eb6fc42 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp @@ -11,37 +11,37 @@ #define PROCNETWIRELESS "/proc/net/wireless" #define IW_LOWER 0 #define IW_UPPER 256 /** * Constructor. Sets hasWirelessExtensions */ -WExtensions::WExtensions(QString interfaceName){ +WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false){ interface = interfaceName; fd = socket( AF_INET, SOCK_DGRAM, 0 ); + if(fd == -1) + return; const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; - else - hasWirelessExtensions = false; } /** * @return QString the station name of the access point. */ QString WExtensions::station(){ if(!hasWirelessExtensions) return QString(); diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro index f28feb2..23fc39a 100644 --- a/noncore/settings/networksettings/wlan/wlan.pro +++ b/noncore/settings/networksettings/wlan/wlan.pro @@ -1,12 +1,12 @@ TEMPLATE = lib CONFIG += qt warn_on release #CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/plugins/networksetup HEADERS = wlanimp.h infoimp.h wlanmodule.h wextensions.h SOURCES = wlanimp.cpp infoimp.cpp wlanmodule.cpp wextensions.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ +INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/ DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -L../interfaces/ -linterfaces INTERFACES = wlan.ui info.ui TARGET = wlanplugin VERSION = 1.0.0 diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 45952b9..7c902e0 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -10,20 +10,28 @@ #include <qdir.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qregexp.h> +#include <qpe/config.h> +#include <qtabwidget.h> +#include "interfacesetupimp.h" -WLANImp::WLANImp( QWidget* parent, const char* name, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ +WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ config = new Config("wireless"); + interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); + //configure->setProfile(currentProfile); + tabWidget->insertTab(interfaceSetup, "TCP/IP"); + readConfig(); + } WLANImp::~WLANImp( ){ delete config; } void WLANImp::readConfig() { @@ -104,19 +112,21 @@ bool WLANImp::writeConfig() return true; return writeWirelessOpts( ); } /** */ void WLANImp::accept() { - if ( writeConfig() ) + if ( writeConfig() ){ + interfaceSetup->saveChanges(); QDialog::accept(); } +} bool WLANImp::writeWirelessOpts( QString scheme ) { qWarning( "WLANImp::writeWirelessOpts entered." ); QString prev = "/etc/pcmcia/wireless.opts"; QFile prevFile(prev); if ( !prevFile.open( IO_ReadOnly ) ) return false; diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h index 59b7c59..608d681 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.h +++ b/noncore/settings/networksettings/wlan/wlanimp.h @@ -1,27 +1,31 @@ #ifndef WLANIMP_H #define WLANIMP_H #include "wlan.h" -#include <qpe/config.h> +class InterfaceSetupImp; +class Interface; +class Config; class WLANImp : public WLAN { Q_OBJECT public: - WLANImp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); ~WLANImp( ); protected: void accept(); private: void readConfig(); bool writeConfig(); bool writeWirelessOpts( QString scheme = "*" ); bool writeWlanngOpts( QString scheme = "*" ); Config* config; + InterfaceSetupImp *interfaceSetup; + }; #endif diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 9ab3b76..c8becb0 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -1,15 +1,17 @@ #include "wlanmodule.h" #include "wlanimp.h" #include "infoimp.h" #include "wextensions.h" +#include "interfaceinformationimp.h" #include <qlabel.h> #include <qprogressbar.h> +#include <qtabwidget.h> /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module() { } /** @@ -48,38 +50,36 @@ bool WLANModule::isOwner(Interface *i){ return false; i->setHardwareName("802.11b"); list.append(i); return true; } /** - * Create, set tabWiget and return the WLANConfigure Module - * @param tabWidget a pointer to the tab widget that this configure has. - * @return QWidget* pointer to the tab widget in this modules configure. + * Create, and return the WLANConfigure Module + * @return QWidget* pointer to this modules configure. */ -QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ - WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", false, Qt::WDestructiveClose); - (*tabWidget) = wlanconfig->tabWidget; +QWidget *WLANModule::configure(Interface *i){ + WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); return wlanconfig; } /** - * Create, set tabWiget and return the Information Module - * @param tabWidget a pointer to the tab widget that this information has. - * @return QWidget* pointer to the tab widget in this modules info. + * Create, and return the Information Module + * @return QWidget* pointer to this modules info. */ -QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ +QWidget *WLANModule::information(Interface *i){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); - (*tabWidget) = info->tabWidget; + InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); + info->tabWidget->insertTab(information, "TCP/IP"); return info; } /** * Get all active (up or down) interfaces * @return QList<Interface> A list of interfaces that exsist that havn't * been called by isOwner() */ diff --git a/noncore/settings/networksettings/wlan/wlanmodule.h b/noncore/settings/networksettings/wlan/wlanmodule.h index 1418ce8..a81ccff 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.h +++ b/noncore/settings/networksettings/wlan/wlanmodule.h @@ -9,18 +9,18 @@ signals: void updateInterface(Interface *i); public: WLANModule(); ~WLANModule(); virtual void setProfile(QString newProfile); virtual bool isOwner(Interface *); - virtual QWidget *configure(Interface *i, QTabWidget **tabWidget); - virtual QWidget *information(Interface *i, QTabWidget **tabWidget); + virtual QWidget *configure(Interface *i); + virtual QWidget *information(Interface *i); virtual QList<Interface> getInterfaces(); virtual void possibleNewInterfaces(QMap<QString, QString> &){}; virtual Interface *addNewInterface(QString name); virtual bool remove(Interface* i); virtual QString getPixmapName(Interface* i); private: QList<Interface> list; |