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,2 +1,4 @@ Write a class that parses /proc and not ifconfig +WLAN needs to be re-written to not use Config +remove WLAN Config item @@ -4,7 +6 @@ Write a class that parses /proc and not ifconfig 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 @@ -20,3 +20,3 @@ <size> - <width>320</width> + <width>240</width> <height>32767</height> @@ -191,3 +191,3 @@ <name>name</name> - <cstring>GroupBox2</cstring> + <cstring>dhcpInformation</cstring> </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 @@ -13,4 +13,4 @@ <y>0</y> - <width>199</width> - <height>244</height> + <width>219</width> + <height>255</height> </rect> @@ -335,2 +335,4 @@ </images> +<connections> +</connections> <tabstops> 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 @@ -5,2 +5,3 @@ #include <qlabel.h> +#include <qgroupbox.h> #include <assert.h> @@ -61,2 +62,4 @@ void InterfaceInformationImp::advanced(){ a->leaseExpiresLabel->setText(interface->getLeaseExpires()); + a->dhcpInformation->setEnabled(interface->isDhcp()); + a->showMaximized(); 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 @@ -347,5 +347,5 @@ bool Interfaces::setMapping(QString interface){ */ -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)); } @@ -406,2 +406,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } + qDebug("Found"); found = true; @@ -410,3 +411,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } - return !found; + return found; } @@ -430,5 +431,6 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString } + found = true; break; } - if((*it).contains(option)){ + if((*it).contains(option) && it != start){ // Found it in stanza so replace it. @@ -443,3 +445,8 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString } - return true; + if(!found){ + QStringList::Iterator p = start; + interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); + found = true; + } + return found; } 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 @@ -45,3 +45,3 @@ public: bool setMapping(QString interface); - void addMapping(QString interfaces); + void addMapping(QString options); bool setMap(QString map, QString value); 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 @@ -13,3 +13,3 @@ <y>0</y> - <width>267</width> + <width>276</width> <height>280</height> @@ -45,64 +45,2 @@ <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> @@ -156,3 +94,3 @@ <name>maxValue</name> - <number>336</number> + <number>87600</number> </property> @@ -164,3 +102,3 @@ <name>value</name> - <number>24</number> + <number>168</number> </property> @@ -200,9 +138,2 @@ </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" > @@ -250,9 +181,2 @@ </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" > @@ -290,2 +214,16 @@ </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> @@ -337,3 +275,2 @@ <tabstop>autoStart</tabstop> - <tabstop>profileCombo</tabstop> <tabstop>dhcpCheckBox</tabstop> 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 @@ -24,3 +24,2 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac interfaces = new Interfaces(); - changeProfile(profileCombo->currentText()); bool error = false; @@ -32,3 +31,2 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac } - connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); } @@ -92,22 +90,9 @@ bool InterfaceSetupImp::saveSettings(){ */ -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."); @@ -115,5 +100,16 @@ void InterfaceSetupImp::changeProfile(const QString &profile){ } + // 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. @@ -121,2 +117,3 @@ void InterfaceSetupImp::changeProfile(const QString &profile){ // DHCP + bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 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 @@ -16,3 +16,5 @@ protected slots: void accept(); - void changeProfile(const QString &profile); + +public slots: + void setProfile(const QString &profile); @@ -22,3 +24,2 @@ private: Interface *interface; - QString currentInterfaceName; 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 @@ -13,3 +13,3 @@ <y>0</y> - <width>230</width> + <width>240</width> <height>289</height> @@ -63,3 +63,3 @@ <name>text</name> - <string>i</string> + <string>s</string> </property> @@ -105,2 +105,16 @@ <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> 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 @@ -34,2 +34,3 @@ +#define SCHEME "/var/lib/pcmcia/scheme"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
@@ -55,3 +56,18 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par 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();
+ }
}
@@ -63,7 +79,6 @@ 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
@@ -207,5 +222,11 @@ void MainWindowImp::configureClicked(){ }
-
+
+ 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;
@@ -215,3 +236,5 @@ void MainWindowImp::configureClicked(){ InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(configure, "TCP/IP");
+ configure->setProfile(currentProfileLabel->text());
+ tabWidget->insertTab(configure, "TCP/IP");
+
}
@@ -224,2 +247,3 @@ void MainWindowImp::configureClicked(){ InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->setProfile(currentProfileLabel->text());
configure->showMaximized();
@@ -246,2 +270,8 @@ void MainWindowImp::informationClicked(){ }
+
+ QStringList list;
+ for(uint i = 0; i < profilesList->count(); i++){
+ list.append(profilesList->text(i));
+ }
+
if(i->getModuleOwner()){
@@ -322,3 +352,3 @@ void MainWindowImp::jobDone(KProcess *process){ 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)) );
@@ -351,3 +381,3 @@ void MainWindowImp::jobDone(KProcess *process){ i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
@@ -408,3 +438,4 @@ void MainWindowImp::updateInterface(Interface *i){ 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(""));
}
@@ -439,3 +470,3 @@ 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;
@@ -443,2 +474,13 @@ void MainWindowImp::removeProfile(){ 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){
@@ -449,3 +491,2 @@ void MainWindowImp::removeProfile(){ }
-
}
@@ -457,3 +498,25 @@ void MainWindowImp::removeProfile(){ 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();
+ }
+ }
+ }
}
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 @@ -99,3 +99,2 @@ bool WLANImp::writeConfig() return writeWirelessOpts( config ); -// return true; } 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 @@ -34,3 +34,3 @@ 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; 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,2 +1,4 @@ Write a class that parses /proc and not ifconfig +WLAN needs to be re-written to not use Config +remove WLAN Config item @@ -4,7 +6 @@ Write a class that parses /proc and not ifconfig 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 @@ -20,3 +20,3 @@ <size> - <width>320</width> + <width>240</width> <height>32767</height> @@ -191,3 +191,3 @@ <name>name</name> - <cstring>GroupBox2</cstring> + <cstring>dhcpInformation</cstring> </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 @@ -13,4 +13,4 @@ <y>0</y> - <width>199</width> - <height>244</height> + <width>219</width> + <height>255</height> </rect> @@ -335,2 +335,4 @@ </images> +<connections> +</connections> <tabstops> 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 @@ -5,2 +5,3 @@ #include <qlabel.h> +#include <qgroupbox.h> #include <assert.h> @@ -61,2 +62,4 @@ void InterfaceInformationImp::advanced(){ a->leaseExpiresLabel->setText(interface->getLeaseExpires()); + a->dhcpInformation->setEnabled(interface->isDhcp()); + a->showMaximized(); 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 @@ -347,5 +347,5 @@ bool Interfaces::setMapping(QString interface){ */ -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)); } @@ -406,2 +406,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } + qDebug("Found"); found = true; @@ -410,3 +411,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } - return !found; + return found; } @@ -430,5 +431,6 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString } + found = true; break; } - if((*it).contains(option)){ + if((*it).contains(option) && it != start){ // Found it in stanza so replace it. @@ -443,3 +445,8 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString } - return true; + if(!found){ + QStringList::Iterator p = start; + interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); + found = true; + } + return found; } 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 @@ -45,3 +45,3 @@ public: bool setMapping(QString interface); - void addMapping(QString interfaces); + void addMapping(QString options); bool setMap(QString map, QString value); 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 @@ -13,3 +13,3 @@ <y>0</y> - <width>267</width> + <width>276</width> <height>280</height> @@ -45,64 +45,2 @@ <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> @@ -156,3 +94,3 @@ <name>maxValue</name> - <number>336</number> + <number>87600</number> </property> @@ -164,3 +102,3 @@ <name>value</name> - <number>24</number> + <number>168</number> </property> @@ -200,9 +138,2 @@ </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" > @@ -250,9 +181,2 @@ </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" > @@ -290,2 +214,16 @@ </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> @@ -337,3 +275,2 @@ <tabstop>autoStart</tabstop> - <tabstop>profileCombo</tabstop> <tabstop>dhcpCheckBox</tabstop> 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 @@ -24,3 +24,2 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac interfaces = new Interfaces(); - changeProfile(profileCombo->currentText()); bool error = false; @@ -32,3 +31,2 @@ InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interfac } - connect(profileCombo, SIGNAL(highlighted(const QString &)), this, SLOT(changeProfile(const QString &))); } @@ -92,22 +90,9 @@ bool InterfaceSetupImp::saveSettings(){ */ -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."); @@ -115,5 +100,16 @@ void InterfaceSetupImp::changeProfile(const QString &profile){ } + // 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. @@ -121,2 +117,3 @@ void InterfaceSetupImp::changeProfile(const QString &profile){ // DHCP + bool error = false; if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) 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 @@ -16,3 +16,5 @@ protected slots: void accept(); - void changeProfile(const QString &profile); + +public slots: + void setProfile(const QString &profile); @@ -22,3 +24,2 @@ private: Interface *interface; - QString currentInterfaceName; 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 @@ -13,3 +13,3 @@ <y>0</y> - <width>230</width> + <width>240</width> <height>289</height> @@ -63,3 +63,3 @@ <name>text</name> - <string>i</string> + <string>s</string> </property> @@ -105,2 +105,16 @@ <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> 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 @@ -34,2 +34,3 @@ +#define SCHEME "/var/lib/pcmcia/scheme"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
@@ -55,3 +56,18 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par 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();
+ }
}
@@ -63,7 +79,6 @@ 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
@@ -207,5 +222,11 @@ void MainWindowImp::configureClicked(){ }
-
+
+ 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;
@@ -215,3 +236,5 @@ void MainWindowImp::configureClicked(){ InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true);
- tabWidget->insertTab(configure, "TCP/IP");
+ configure->setProfile(currentProfileLabel->text());
+ tabWidget->insertTab(configure, "TCP/IP");
+
}
@@ -224,2 +247,3 @@ void MainWindowImp::configureClicked(){ InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true);
+ configure->setProfile(currentProfileLabel->text());
configure->showMaximized();
@@ -246,2 +270,8 @@ void MainWindowImp::informationClicked(){ }
+
+ QStringList list;
+ for(uint i = 0; i < profilesList->count(); i++){
+ list.append(profilesList->text(i));
+ }
+
if(i->getModuleOwner()){
@@ -322,3 +352,3 @@ void MainWindowImp::jobDone(KProcess *process){ 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)) );
@@ -351,3 +381,3 @@ void MainWindowImp::jobDone(KProcess *process){ i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setHardwareName("Disconnected");
interfaceNames.insert(i->getInterfaceName(), i);
@@ -408,3 +438,4 @@ void MainWindowImp::updateInterface(Interface *i){ 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(""));
}
@@ -439,3 +470,3 @@ 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;
@@ -443,2 +474,13 @@ void MainWindowImp::removeProfile(){ 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){
@@ -449,3 +491,2 @@ void MainWindowImp::removeProfile(){ }
-
}
@@ -457,3 +498,25 @@ void MainWindowImp::removeProfile(){ 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();
+ }
+ }
+ }
}
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 @@ -99,3 +99,2 @@ bool WLANImp::writeConfig() return writeWirelessOpts( config ); -// return true; } 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 @@ -34,3 +34,3 @@ 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; |