author | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-18 14:28:42 (UTC) |
commit | 88b3a159060ed7057bfee4cc1ccfcf81a63a4780 (patch) (side-by-side diff) | |
tree | 3dd78d403f337c73bb3ca9d75ef0a29f2adae9b6 | |
parent | 461113126af82cd6343eedab36ecabb4253780ee (diff) | |
download | opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.zip opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.gz opie-88b3a159060ed7057bfee4cc1ccfcf81a63a4780.tar.bz2 |
More profile stuff works
26 files changed, 310 insertions, 272 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index c8e2989..c587f58 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO @@ -1,10 +1,6 @@ Write a class that parses /proc and not ifconfig +WLAN needs to be re-written to not use Config +remove WLAN Config item [ ] Wlanmodule needs to check if an interface supports wireless extensions. -[x] When you set options in wlanmodule, hit OK, it exits all of - networksetup, doesnt bring you back to the main screen. -[x] Wlanmodule isnt writing out wireless.opts -[ ] Need a means of bringing an interface up and down (calling - out ifup/ifdown) from the gui. - -Ben- Click information, then click up or down... :-D diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui index efe67b0..0ec67c2 100644 --- a/noncore/net/networksetup/interfaceadvanced.ui +++ b/noncore/net/networksetup/interfaceadvanced.ui @@ -1,45 +1,45 @@ <!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>320</width> + <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> @@ -168,49 +168,49 @@ <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>GroupBox2</cstring> + <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> diff --git a/noncore/net/networksetup/interfaceinformation.ui b/noncore/net/networksetup/interfaceinformation.ui index 76af19c..fc99fce 100644 --- a/noncore/net/networksetup/interfaceinformation.ui +++ b/noncore/net/networksetup/interfaceinformation.ui @@ -1,39 +1,39 @@ <!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>199</width> - <height>244</height> + <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> @@ -312,32 +312,34 @@ </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> +<connections> +</connections> <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 index 59a6400..43483fb 100644 --- a/noncore/net/networksetup/interfaceinformationimp.cpp +++ b/noncore/net/networksetup/interfaceinformationimp.cpp @@ -1,29 +1,30 @@ #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). @@ -38,30 +39,32 @@ void InterfaceInformationImp::updateInterface(Interface *i){ 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/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp index 1287d90..eef42df 100644 --- a/noncore/net/networksetup/interfaces.cpp +++ b/noncore/net/networksetup/interfaces.cpp @@ -324,51 +324,51 @@ bool Interfaces::setInterfaceOption(QString option, QString 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 interfaces){ +void Interfaces::addMapping(QString option){ interfaces.append(""); - interfaces.append(QString(MAPPING " %1").arg(interfaces)); + interfaces.append(QString(MAPPING " %1").arg(option)); } /** * 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); } /** * 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. @@ -383,86 +383,93 @@ bool Interfaces::setScript(QString 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)){ if(found == true){ qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); } + qDebug("Found"); found = true; iterator = it; } } - return !found; + 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)){ + if((*it).contains(option) && it != start){ // 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; if(value == "") (*it) = ""; else (*it) = QString("\t%1 %2").arg(option).arg(value); } } - return true; + if(!found){ + QStringList::Iterator p = start; + interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); + found = true; + } + 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; } diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h index 8b4788c..e617c17 100644 --- a/noncore/net/networksetup/interfaces.h +++ b/noncore/net/networksetup/interfaces.h @@ -22,49 +22,49 @@ 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 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 removeAllInterfaceOptions(); bool setMapping(QString interface); - void addMapping(QString interfaces); + void addMapping(QString options); bool setMap(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); 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 index 3db9a0b..c94b1be 100644 --- a/noncore/net/networksetup/interfacesetup.ui +++ b/noncore/net/networksetup/interfacesetup.ui @@ -1,131 +1,69 @@ <!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>267</width> + <width>276</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>Automaticly bring up</string> </property> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout8</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>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Profile</string> - </property> - </widget> - <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>All</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>profileCombo</cstring> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer20</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> - </hbox> - </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> @@ -133,215 +71,214 @@ </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>336</number> + <number>87600</number> </property> <property stdset="1"> <name>minValue</name> <number>1</number> </property> <property stdset="1"> <name>value</name> - <number>24</number> + <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="3" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>firstDNSLineEdit</cstring> - </property> - </widget> <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="4" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>secondDNSLineEdit</cstring> - </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>profileCombo</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 index 951aeee..c16d821 100644 --- a/noncore/net/networksetup/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfacesetupimp.cpp @@ -1,57 +1,55 @@ #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(); - changeProfile(profileCombo->currentText()); bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } - connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); } /** * Save the current settings, then write out the interfaces file and close. */ void InterfaceSetupImp::accept(){ if(!saveSettings()) return; interfaces->write(); close(true); } /** * Save the settings for the current Interface. * @return bool true if successfull, false otherwise */ bool InterfaceSetupImp::saveSettings(){ // eh can't really do anything about it other then return. :-D if(!interfaces->isInterfaceSet()) return true; bool error = false; // Loopback case if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ @@ -69,77 +67,76 @@ bool InterfaceSetupImp::saveSettings(){ 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::changeProfile(const QString &profile){ - QString newInterfaceName; - if(profile.lower() == "all") - newInterfaceName = interface->getInterfaceName(); - else - newInterfaceName = interface->getInterfaceName() + "_" + profile; - if(newInterfaceName == currentInterfaceName) - return; - else{ - saveSettings(); - currentInterfaceName = newInterfaceName; - } - bool error = interfaces->setInterface(currentInterfaceName); +void InterfaceSetupImp::setProfile(const QString &profile){ + QString newInterfaceName = interface->getInterfaceName() + profile; // See if we have to make a interface. - if(error){ - qDebug("InterfaceSetupImp: Adding a new interface from profile change."); - interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); - error = interfaces->setInterface(currentInterfaceName); - if(error){ + if(!interfaces->setInterface(newInterfaceName)){ + interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); + if(!interfaces->setInterface(newInterfaceName)){ qDebug("InterfaceSetupImp: Added interface, but still can't set."); return; } + // Add making for this new interface if need too + if(profile != ""){ + 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->setScript("getprofile.sh"); + interfaces->setMap("map", newInterfaceName); + } } - //qDebug( currentInterfaceName.latin1() ); // 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 index 6c34718..7df0d46 100644 --- a/noncore/net/networksetup/interfacesetupimp.h +++ b/noncore/net/networksetup/interfacesetupimp.h @@ -1,30 +1,31 @@ #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(); - void changeProfile(const QString &profile); + +public slots: + void setProfile(const QString &profile); private: bool saveSettings(); Interfaces *interfaces; Interface *interface; - QString currentInterfaceName; }; #endif // interfacesetupimp.h diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui index bea999b..3d30994 100644 --- a/noncore/net/networksetup/mainwindow.ui +++ b/noncore/net/networksetup/mainwindow.ui @@ -1,38 +1,38 @@ <!DOCTYPE UI><UI> <class>MainWindow</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>MainWindow</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>230</width> + <width>240</width> <height>289</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Network Setup</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <property> <name>layoutMargin</name> @@ -40,90 +40,104 @@ <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget3</cstring> </property> <attribute> <name>title</name> <string>Connections</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QListView</class> <column> <property> <name>text</name> - <string>i</string> + <string>s</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> <string>t</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> <string>Name</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> + <string>in</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> <string>IP</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <property stdset="1"> <name>name</name> <cstring>connectionList</cstring> </property> <property stdset="1"> <name>allColumnsShowFocus</name> <bool>true</bool> </property> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index a446d29..3c0af6a 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -11,82 +11,97 @@ #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>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qlist.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#define TEMP_ALL "/tmp/ifconfig-a"
#define TEMP_UP "/tmp/ifconfig"
+#define SCHEME "/var/lib/pcmcia/scheme"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
+ currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
+
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadOnly) ) { // file opened successfully
+ QTextStream stream( &file ); // use a text stream
+ while ( !stream.eof() ) { // until end of file...
+ QString line = stream.readLine(); // line of text excluding '\n'
+ if(line.contains("SCHEME")){
+ line = line.mid(7, line.length());
+ currentProfileLabel->setText(line);
+ break;
+ }
+ }
+ file.close();
+ }
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
// Save profiles.
- if(profiles.count() > 1){
- Config cfg("NetworkSetup");
- cfg.setGroup("General");
- cfg.writeEntry("Profiles", profiles.join(" "));
- }
+ Config cfg("NetworkSetup");
+ cfg.setGroup("General");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
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
*/
void MainWindowImp::loadModules(QString path){
qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
@@ -184,87 +199,102 @@ void MainWindowImp::removeClicked(){ }
else{
if(!i->getModuleOwner()->remove(i))
QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
else{
QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
// TODO memory managment....
// who deletes the interface?
}
}
}
/**
* Pull up the configure about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure with a empty
* tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
-
+
+ QString currentProfile = currentProfileLabel->text();
+ if(profilesList->count() <= 1 || currentProfile == "All"){
+ currentProfile = "";
+ }
+
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
+ i->getModuleOwner()->setProfile(currentProfileLabel->text());
QTabWidget *tabWidget = NULL;
QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
if(moduleConfigure != NULL){
if(tabWidget != NULL){
InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(configure, "TCP/IP");
+ configure->setProfile(currentProfileLabel->text());
+ tabWidget->insertTab(configure, "TCP/IP");
+
}
moduleConfigure->showMaximized();
moduleConfigure->show();
return;
}
}
InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->setProfile(currentProfileLabel->text());
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.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(!i->isAttached()){
QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
return;
}
+
+ 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(&tabWidget);
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
*/
void MainWindowImp::getInterfaceList(){
@@ -299,78 +329,78 @@ void MainWindowImp::jobDone(KProcess *process){ QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
QString interfaceName = line.mid(0, space);
Interface *i;
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(this, interfaceName, false);
else
i = new Interface(this, interfaceName, true);
i->setAttached(true);
QString hardName = "Ethernet";
int hardwareName = line.find("Link encap:");
int macAddress = line.find("HWaddr");
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
// It was an interface we already had.
else{
if(fileName != TEMP_ALL)
(interfaceNames[interfaceName])->setStatus(true);
}
}
}
file.close();
QFile::remove(fileName);
if(threads.count() == 0){
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
if(it.key() == (*ni))
found = true;
}
if(!found){
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
}
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i){
if(!advancedUserMode){
if(i->getInterfaceName() == "lo")
return;
}
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
@@ -385,78 +415,111 @@ void MainWindowImp::updateInterface(Interface *i){ else
item = items[i];
// Update the icons and information
item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
QString typeName = "lan";
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
if(i->getInterfaceName().contains("usb"))
typeName = "usb";
if(!i->isAttached())
typeName = "connect_no";
// Actually try to use the Module
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
item->setPixmap(1, (Resource::loadPixmap(typeName)));
item->setText(2, i->getHardwareName());
- item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
+ item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
+ item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
void MainWindowImp::newProfileChanged(const QString& newText){
if(newText.length() > 0)
newProfileButton->setEnabled(true);
else
newProfileButton->setEnabled(false);
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
QString newProfileName = newProfile->text();
if(profiles.grep(newProfileName).count() > 0){
QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
- QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
+ QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
return;
}
QString profileToRemove = profilesList->currentText();
+ if(profileToRemove == "All"){
+ QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
+ return;
+ }
+ // Can't remove the curent profile
+ if(profileToRemove == currentProfileLabel->text()){
+ QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
+ return;
+
+ }
+
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
-
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(){
- currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
+ if(profilesList->currentItem() == -1){
+ QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
+ return;
+ }
+ QString newProfile = profilesList->text(profilesList->currentItem());
+ if(newProfile != currentProfileLabel->text()){
+ currentProfileLabel->setText(newProfile);
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadWrite) ) {
+ QTextStream stream( &file );
+ stream << QString("SCHEME=%1").arg(newProfile);
+ file.close();
+ }
+ // restart all up devices?
+ if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
+ // Go through them one by one
+ QMap<Interface*, QListViewItem*>::Iterator it;
+ for( it = items.begin(); it != items.end(); ++it ){
+ if(it.key()->getStatus() == true)
+ it.key()->restart();
+ }
+ }
+ }
}
// mainwindowimp.cpp
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index 74eef5f..517604f 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp @@ -76,49 +76,48 @@ bool WLANImp::writeConfig() if( networkInfrastructure->isChecked() ){ config.writeEntry( "Mode", "Managed" ); } else if( network802->isChecked() ){ config.writeEntry( "Mode", "adhoc" ); } config.writeEntry( "CHANNEL", networkChannel->value() ); // config.readEntry( "RATE", "auto" ); wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); if( keyRadio0->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 0 ); } else if( keyRadio1->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 1 ); } else if( keyRadio2->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 2 ); } else if( keyRadio3->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 3 ); } config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); return writeWirelessOpts( config ); -// return true; } /** */ void WLANImp::accept() { if ( writeConfig() ) QDialog::accept(); } void WLANImp::done ( int r ) { QDialog::done ( r ); close ( ); } bool WLANImp::writeWirelessOpts( Config &config, 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/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index 9d34d75..53b5857 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp @@ -11,49 +11,49 @@ WLANModule::WLANModule() : Module() { /** * Change the current profile */ void WLANModule::setProfile(QString newProfile){ profile = newProfile; } /** * get the icon name for this device. * @param Interface* can be used in determining the icon. * @return QString the icon name (minus .png, .gif etc) */ QString WLANModule::getPixmapName(Interface* ){ return "wlan"; } /** * 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. */ bool WLANModule::isOwner(Interface *i){ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ - i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); + i->setHardwareName("802.11b"); return true; } return false; } /** * 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. */ QWidget *WLANModule::configure(QTabWidget **tabWidget){ Config *cfg = new Config("wireless"); WLANImp *wlanconfig = new WLANImp(*cfg); (*tabWidget) = wlanconfig->tabWidget; 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. */ QWidget *WLANModule::information(QTabWidget **tabWidget){ return NULL; diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index c8e2989..c587f58 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO @@ -1,10 +1,6 @@ Write a class that parses /proc and not ifconfig +WLAN needs to be re-written to not use Config +remove WLAN Config item [ ] Wlanmodule needs to check if an interface supports wireless extensions. -[x] When you set options in wlanmodule, hit OK, it exits all of - networksetup, doesnt bring you back to the main screen. -[x] Wlanmodule isnt writing out wireless.opts -[ ] Need a means of bringing an interface up and down (calling - out ifup/ifdown) from the gui. - -Ben- Click information, then click up or down... :-D diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui index efe67b0..0ec67c2 100644 --- a/noncore/settings/networksettings/interfaceadvanced.ui +++ b/noncore/settings/networksettings/interfaceadvanced.ui @@ -1,45 +1,45 @@ <!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>320</width> + <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> @@ -168,49 +168,49 @@ <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>GroupBox2</cstring> + <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> diff --git a/noncore/settings/networksettings/interfaceinformation.ui b/noncore/settings/networksettings/interfaceinformation.ui index 76af19c..fc99fce 100644 --- a/noncore/settings/networksettings/interfaceinformation.ui +++ b/noncore/settings/networksettings/interfaceinformation.ui @@ -1,39 +1,39 @@ <!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>199</width> - <height>244</height> + <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> @@ -312,32 +312,34 @@ </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> +<connections> +</connections> <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 index 59a6400..43483fb 100644 --- a/noncore/settings/networksettings/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaceinformationimp.cpp @@ -1,29 +1,30 @@ #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). @@ -38,30 +39,32 @@ void InterfaceInformationImp::updateInterface(Interface *i){ 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/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp index 1287d90..eef42df 100644 --- a/noncore/settings/networksettings/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces.cpp @@ -324,51 +324,51 @@ bool Interfaces::setInterfaceOption(QString option, QString 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 interfaces){ +void Interfaces::addMapping(QString option){ interfaces.append(""); - interfaces.append(QString(MAPPING " %1").arg(interfaces)); + interfaces.append(QString(MAPPING " %1").arg(option)); } /** * 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); } /** * 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. @@ -383,86 +383,93 @@ bool Interfaces::setScript(QString 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)){ if(found == true){ qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); } + qDebug("Found"); found = true; iterator = it; } } - return !found; + 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)){ + if((*it).contains(option) && it != start){ // 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; if(value == "") (*it) = ""; else (*it) = QString("\t%1 %2").arg(option).arg(value); } } - return true; + if(!found){ + QStringList::Iterator p = start; + interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); + found = true; + } + 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; } diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h index 8b4788c..e617c17 100644 --- a/noncore/settings/networksettings/interfaces.h +++ b/noncore/settings/networksettings/interfaces.h @@ -22,49 +22,49 @@ 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 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 removeAllInterfaceOptions(); bool setMapping(QString interface); - void addMapping(QString interfaces); + void addMapping(QString options); bool setMap(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); 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 index 3db9a0b..c94b1be 100644 --- a/noncore/settings/networksettings/interfacesetup.ui +++ b/noncore/settings/networksettings/interfacesetup.ui @@ -1,131 +1,69 @@ <!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>267</width> + <width>276</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>Automaticly bring up</string> </property> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>Layout8</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>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Profile</string> - </property> - </widget> - <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>All</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>profileCombo</cstring> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer20</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> - </hbox> - </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> @@ -133,215 +71,214 @@ </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>336</number> + <number>87600</number> </property> <property stdset="1"> <name>minValue</name> <number>1</number> </property> <property stdset="1"> <name>value</name> - <number>24</number> + <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="3" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>firstDNSLineEdit</cstring> - </property> - </widget> <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="4" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>secondDNSLineEdit</cstring> - </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>profileCombo</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 index 951aeee..c16d821 100644 --- a/noncore/settings/networksettings/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfacesetupimp.cpp @@ -1,57 +1,55 @@ #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(); - changeProfile(profileCombo->currentText()); bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ staticGroupBox->hide(); dhcpCheckBox->hide(); leaseTime->hide(); leaseHoursLabel->hide(); } - connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); } /** * Save the current settings, then write out the interfaces file and close. */ void InterfaceSetupImp::accept(){ if(!saveSettings()) return; interfaces->write(); close(true); } /** * Save the settings for the current Interface. * @return bool true if successfull, false otherwise */ bool InterfaceSetupImp::saveSettings(){ // eh can't really do anything about it other then return. :-D if(!interfaces->isInterfaceSet()) return true; bool error = false; // Loopback case if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ @@ -69,77 +67,76 @@ bool InterfaceSetupImp::saveSettings(){ 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::changeProfile(const QString &profile){ - QString newInterfaceName; - if(profile.lower() == "all") - newInterfaceName = interface->getInterfaceName(); - else - newInterfaceName = interface->getInterfaceName() + "_" + profile; - if(newInterfaceName == currentInterfaceName) - return; - else{ - saveSettings(); - currentInterfaceName = newInterfaceName; - } - bool error = interfaces->setInterface(currentInterfaceName); +void InterfaceSetupImp::setProfile(const QString &profile){ + QString newInterfaceName = interface->getInterfaceName() + profile; // See if we have to make a interface. - if(error){ - qDebug("InterfaceSetupImp: Adding a new interface from profile change."); - interfaces->addInterface(currentInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); - error = interfaces->setInterface(currentInterfaceName); - if(error){ + if(!interfaces->setInterface(newInterfaceName)){ + interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); + if(!interfaces->setInterface(newInterfaceName)){ qDebug("InterfaceSetupImp: Added interface, but still can't set."); return; } + // Add making for this new interface if need too + if(profile != ""){ + 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->setScript("getprofile.sh"); + interfaces->setMap("map", newInterfaceName); + } } - //qDebug( currentInterfaceName.latin1() ); // 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 index 6c34718..7df0d46 100644 --- a/noncore/settings/networksettings/interfacesetupimp.h +++ b/noncore/settings/networksettings/interfacesetupimp.h @@ -1,30 +1,31 @@ #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(); - void changeProfile(const QString &profile); + +public slots: + void setProfile(const QString &profile); private: bool saveSettings(); Interfaces *interfaces; Interface *interface; - QString currentInterfaceName; }; #endif // interfacesetupimp.h diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui index bea999b..3d30994 100644 --- a/noncore/settings/networksettings/mainwindow.ui +++ b/noncore/settings/networksettings/mainwindow.ui @@ -1,38 +1,38 @@ <!DOCTYPE UI><UI> <class>MainWindow</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>MainWindow</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>230</width> + <width>240</width> <height>289</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Network Setup</string> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <property> <name>layoutMargin</name> @@ -40,90 +40,104 @@ <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>Widget3</cstring> </property> <attribute> <name>title</name> <string>Connections</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QListView</class> <column> <property> <name>text</name> - <string>i</string> + <string>s</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> <string>t</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> <string>Name</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <column> <property> <name>text</name> + <string>in</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> <string>IP</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <property stdset="1"> <name>name</name> <cstring>connectionList</cstring> </property> <property stdset="1"> <name>allColumnsShowFocus</name> <bool>true</bool> </property> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index a446d29..3c0af6a 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -11,82 +11,97 @@ #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>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qlist.h>
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#define TEMP_ALL "/tmp/ifconfig-a"
#define TEMP_UP "/tmp/ifconfig"
+#define SCHEME "/var/lib/pcmcia/scheme"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
// Load connections.
loadModules(QPEApplication::qpeDir() + "/plugins/networksetup");
getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
+ currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
+
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadOnly) ) { // file opened successfully
+ QTextStream stream( &file ); // use a text stream
+ while ( !stream.eof() ) { // until end of file...
+ QString line = stream.readLine(); // line of text excluding '\n'
+ if(line.contains("SCHEME")){
+ line = line.mid(7, line.length());
+ currentProfileLabel->setText(line);
+ break;
+ }
+ }
+ file.close();
+ }
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp(){
// Save profiles.
- if(profiles.count() > 1){
- Config cfg("NetworkSetup");
- cfg.setGroup("General");
- cfg.writeEntry("Profiles", profiles.join(" "));
- }
+ Config cfg("NetworkSetup");
+ cfg.setGroup("General");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
delete it.key();
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
*/
void MainWindowImp::loadModules(QString path){
qDebug(path.latin1());
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
@@ -184,87 +199,102 @@ void MainWindowImp::removeClicked(){ }
else{
if(!i->getModuleOwner()->remove(i))
QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
else{
QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
// TODO memory managment....
// who deletes the interface?
}
}
}
/**
* Pull up the configure about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure with a empty
* tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
-
+
+ QString currentProfile = currentProfileLabel->text();
+ if(profilesList->count() <= 1 || currentProfile == "All"){
+ currentProfile = "";
+ }
+
Interface *i = interfaceItems[item];
if(i->getModuleOwner()){
+ i->getModuleOwner()->setProfile(currentProfileLabel->text());
QTabWidget *tabWidget = NULL;
QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget);
if(moduleConfigure != NULL){
if(tabWidget != NULL){
InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(configure, "TCP/IP");
+ configure->setProfile(currentProfileLabel->text());
+ tabWidget->insertTab(configure, "TCP/IP");
+
}
moduleConfigure->showMaximized();
moduleConfigure->show();
return;
}
}
InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->setProfile(currentProfileLabel->text());
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.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(!i->isAttached()){
QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
return;
}
+
+ 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(&tabWidget);
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
*/
void MainWindowImp::getInterfaceList(){
@@ -299,78 +329,78 @@ void MainWindowImp::jobDone(KProcess *process){ QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
QString interfaceName = line.mid(0, space);
Interface *i;
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(this, interfaceName, false);
else
i = new Interface(this, interfaceName, true);
i->setAttached(true);
QString hardName = "Ethernet";
int hardwareName = line.find("Link encap:");
int macAddress = line.find("HWaddr");
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) );
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
// It was an interface we already had.
else{
if(fileName != TEMP_ALL)
(interfaceNames[interfaceName])->setStatus(true);
}
}
}
file.close();
QFile::remove(fileName);
if(threads.count() == 0){
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
if(it.key() == (*ni))
found = true;
}
if(!found){
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
}
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i){
if(!advancedUserMode){
if(i->getInterfaceName() == "lo")
return;
}
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
@@ -385,78 +415,111 @@ void MainWindowImp::updateInterface(Interface *i){ else
item = items[i];
// Update the icons and information
item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
QString typeName = "lan";
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
if(i->getInterfaceName().contains("usb"))
typeName = "usb";
if(!i->isAttached())
typeName = "connect_no";
// Actually try to use the Module
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
item->setPixmap(1, (Resource::loadPixmap(typeName)));
item->setText(2, i->getHardwareName());
- item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
+ item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
+ item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
void MainWindowImp::newProfileChanged(const QString& newText){
if(newText.length() > 0)
newProfileButton->setEnabled(true);
else
newProfileButton->setEnabled(false);
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
QString newProfileName = newProfile->text();
if(profiles.grep(newProfileName).count() > 0){
QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
- QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
+ QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok");
return;
}
QString profileToRemove = profilesList->currentText();
+ if(profileToRemove == "All"){
+ QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok");
+ return;
+ }
+ // Can't remove the curent profile
+ if(profileToRemove == currentProfileLabel->text()){
+ QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok");
+ return;
+
+ }
+
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
-
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(){
- currentProfileLabel->setText(profilesList->text(profilesList->currentItem()));
+ if(profilesList->currentItem() == -1){
+ QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
+ return;
+ }
+ QString newProfile = profilesList->text(profilesList->currentItem());
+ if(newProfile != currentProfileLabel->text()){
+ currentProfileLabel->setText(newProfile);
+ QFile file(SCHEME);
+ if ( file.open(IO_ReadWrite) ) {
+ QTextStream stream( &file );
+ stream << QString("SCHEME=%1").arg(newProfile);
+ file.close();
+ }
+ // restart all up devices?
+ if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
+ // Go through them one by one
+ QMap<Interface*, QListViewItem*>::Iterator it;
+ for( it = items.begin(); it != items.end(); ++it ){
+ if(it.key()->getStatus() == true)
+ it.key()->restart();
+ }
+ }
+ }
}
// mainwindowimp.cpp
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 74eef5f..517604f 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp @@ -76,49 +76,48 @@ bool WLANImp::writeConfig() if( networkInfrastructure->isChecked() ){ config.writeEntry( "Mode", "Managed" ); } else if( network802->isChecked() ){ config.writeEntry( "Mode", "adhoc" ); } config.writeEntry( "CHANNEL", networkChannel->value() ); // config.readEntry( "RATE", "auto" ); wepEnabled->isChecked() ? config.writeEntry( "dot11PrivacyInvoked", "true" ) : config.writeEntry( "dot11PrivacyInvoked", "false" ); authOpen->isChecked() ? config.writeEntry( "AuthType", "opensystem" ) : config.writeEntry( "AuthType", "sharedkey" ); key40->isChecked() ? config.writeEntry( "PRIV_KEY128", "false" ) : config.writeEntry( "PRIV_KEY128", "true" ); if( keyRadio0->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 0 ); } else if( keyRadio1->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 1 ); } else if( keyRadio2->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 2 ); } else if( keyRadio3->isChecked() ){ config.writeEntry( "dot11WEPDefaultKeyID", 3 ); } config.writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); config.writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); config.writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); config.writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); return writeWirelessOpts( config ); -// return true; } /** */ void WLANImp::accept() { if ( writeConfig() ) QDialog::accept(); } void WLANImp::done ( int r ) { QDialog::done ( r ); close ( ); } bool WLANImp::writeWirelessOpts( Config &config, 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/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 9d34d75..53b5857 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -11,49 +11,49 @@ WLANModule::WLANModule() : Module() { /** * Change the current profile */ void WLANModule::setProfile(QString newProfile){ profile = newProfile; } /** * get the icon name for this device. * @param Interface* can be used in determining the icon. * @return QString the icon name (minus .png, .gif etc) */ QString WLANModule::getPixmapName(Interface* ){ return "wlan"; } /** * 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. */ bool WLANModule::isOwner(Interface *i){ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ - i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName())); + i->setHardwareName("802.11b"); return true; } return false; } /** * 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. */ QWidget *WLANModule::configure(QTabWidget **tabWidget){ Config *cfg = new Config("wireless"); WLANImp *wlanconfig = new WLANImp(*cfg); (*tabWidget) = wlanconfig->tabWidget; 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. */ QWidget *WLANModule::information(QTabWidget **tabWidget){ return NULL; |