-rw-r--r-- | noncore/net/networksetup/interface.cpp | 16 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindow.ui | 16 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 73 | ||||
-rw-r--r-- | noncore/net/networksetup/networksetup.pro | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindow.ui | 16 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 73 | ||||
-rw-r--r-- | noncore/settings/networksettings/networksetup.pro | 4 |
8 files changed, 148 insertions, 70 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index 5b21364..1f32093 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp @@ -3,2 +3,3 @@ #include <qfile.h> +#include <qdir.h> #include <qfileinfo.h> @@ -129,5 +130,10 @@ bool Interface::refresh(){ dhcp = false; - + + QString dhcpDirectory(HDCP_INFO_DIR); + QDir d(dhcpDirectory); + if(!d.exists(dhcpDirectory)) + dhcpDirectory = "/var/run"; + // See if we have - QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); + QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); // If there is no DHCP information then exit now with no errors. @@ -150,4 +156,4 @@ bool Interface::refresh(){ line = stream.readLine(); - if(line.contains("DHCPSID=")) - dhcpServerIp = line.mid(8, line.length()); + if(line.contains("DHCPSIADDR=")) + dhcpServerIp = line.mid(11, line.length()); if(line.contains("LEASETIME=")) @@ -162,3 +168,3 @@ bool Interface::refresh(){ // Get the pid of the deamond - dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); + dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); file.setName(dhcpFile); diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui index f5b104a..3538aeb 100644 --- a/noncore/net/networksetup/mainwindow.ui +++ b/noncore/net/networksetup/mainwindow.ui @@ -47,3 +47,3 @@ <name>title</name> - <string>Interfaces</string> + <string>Connections</string> </attribute> @@ -102,2 +102,16 @@ </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"> diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 66ec8b5..e9429e3 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp @@ -7,2 +7,3 @@ #include "kprocess.h"
+#include "namedialog.h"
@@ -130,2 +131,3 @@ void MainWindowImp::addClicked(){ QMap<QString, QString> list;
+ QMap<QString, Module*> newInterfaceOwners;
list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
@@ -133,4 +135,5 @@ void MainWindowImp::addClicked(){ for( it = libraries.begin(); it != libraries.end(); ++it ){
- if(it.key())
+ if(it.key()){
(it.key())->possibleNewInterfaces(list);
+ }
}
@@ -145,3 +148,15 @@ void MainWindowImp::addClicked(){ if(QDialog::Accepted == addNewConnection.exec()){
-
+ QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
+ if(!item)
+ return;
+
+ for( it = libraries.begin(); it != libraries.end(); ++it ){
+ if(it.key()){
+ Interface *i = (it.key())->addNewInterface(item->text(0));
+ if(i){
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ }
+ }
+ }
}
@@ -155,8 +170,9 @@ void MainWindowImp::removeClicked(){ QListViewItem *item = connectionList->currentItem();
- if(item == NULL) {
- QMessageBox::information(this, "Error","Please select an interface.", "Ok");
- return;
+ if(!item) {
+ QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ return;
}
- if((interfaceItems[item])->getModuleOwner() == NULL){
+ Interface *i = interfaceItems[item];
+ if(i->getModuleOwner() == NULL){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
@@ -164,5 +180,10 @@ void MainWindowImp::removeClicked(){ else{
- // Try to remove.
+ 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?
+ }
}
-
}
@@ -313,3 +334,4 @@ void MainWindowImp::jobDone(KProcess *process){ /**
- *
+ * Update this interface. If no QListViewItem exists create one.
+ * @param Interface* pointer to the interface that needs to be updated.
*/
@@ -318,3 +340,3 @@ void MainWindowImp::updateInterface(Interface *i){ - // See if we already have it
+ // Find the interface, making it if needed.
if(items.find(i) == items.end()){
@@ -327,3 +349,2 @@ void MainWindowImp::updateInterface(Interface *i){ }
-
items.insert(i, item);
@@ -333,8 +354,5 @@ void MainWindowImp::updateInterface(Interface *i){ item = items[i];
-
- QString statusImage = "down";
- if(i->getStatus())
- statusImage = "up";
- QPixmap status = (Resource::loadPixmap(statusImage));
- item->setPixmap(0, status);
+
+ // Update the icons and information
+ item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
@@ -348,10 +366,8 @@ void MainWindowImp::updateInterface(Interface *i){ // Actually try to use the Module
- if(i->getModuleOwner() != NULL){
+ if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
- }
- QPixmap type = (Resource::loadPixmap(typeName));
- item->setPixmap(1, type);
-
- item->setText(2, i->getHardwareName());
+ item->setPixmap(1, (Resource::loadPixmap(typeName)));
+ item->setText(2, i->getHardwareName());
+ item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
}
@@ -361,8 +377,12 @@ void MainWindowImp::updateInterface(Interface *i){ * Don't add profiles that already exists.
- * Appends to the combo and QStringList
+ * Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
- QString newProfileName = "New";
+ NameDialog foo(this, "namedialog", true);
+ QString newProfileName = foo.go();
+ if(newProfileName.length() == 0)
+ return;
+
if(profiles.grep(newProfileName).count() > 0){
- QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
+ QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
return;
@@ -371,3 +391,2 @@ void MainWindowImp::addProfile(){ profilesList->insertItem(newProfileName);
-
}
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro index ba70180..e146eb4 100644 --- a/noncore/net/networksetup/networksetup.pro +++ b/noncore/net/networksetup/networksetup.pro @@ -3,4 +3,4 @@ TEMPLATE = app CONFIG = qt warn_on release -HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h -SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp +HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h namedialog.h +SOURCES = main.cpp namedialog.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp #INCLUDEPATH += $(QPEDIR)/include diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index 5b21364..1f32093 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp @@ -3,2 +3,3 @@ #include <qfile.h> +#include <qdir.h> #include <qfileinfo.h> @@ -129,5 +130,10 @@ bool Interface::refresh(){ dhcp = false; - + + QString dhcpDirectory(HDCP_INFO_DIR); + QDir d(dhcpDirectory); + if(!d.exists(dhcpDirectory)) + dhcpDirectory = "/var/run"; + // See if we have - QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); + QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName)); // If there is no DHCP information then exit now with no errors. @@ -150,4 +156,4 @@ bool Interface::refresh(){ line = stream.readLine(); - if(line.contains("DHCPSID=")) - dhcpServerIp = line.mid(8, line.length()); + if(line.contains("DHCPSIADDR=")) + dhcpServerIp = line.mid(11, line.length()); if(line.contains("LEASETIME=")) @@ -162,3 +168,3 @@ bool Interface::refresh(){ // Get the pid of the deamond - dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); + dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName)); file.setName(dhcpFile); diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui index f5b104a..3538aeb 100644 --- a/noncore/settings/networksettings/mainwindow.ui +++ b/noncore/settings/networksettings/mainwindow.ui @@ -47,3 +47,3 @@ <name>title</name> - <string>Interfaces</string> + <string>Connections</string> </attribute> @@ -102,2 +102,16 @@ </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"> diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 66ec8b5..e9429e3 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -7,2 +7,3 @@ #include "kprocess.h"
+#include "namedialog.h"
@@ -130,2 +131,3 @@ void MainWindowImp::addClicked(){ QMap<QString, QString> list;
+ QMap<QString, Module*> newInterfaceOwners;
list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
@@ -133,4 +135,5 @@ void MainWindowImp::addClicked(){ for( it = libraries.begin(); it != libraries.end(); ++it ){
- if(it.key())
+ if(it.key()){
(it.key())->possibleNewInterfaces(list);
+ }
}
@@ -145,3 +148,15 @@ void MainWindowImp::addClicked(){ if(QDialog::Accepted == addNewConnection.exec()){
-
+ QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
+ if(!item)
+ return;
+
+ for( it = libraries.begin(); it != libraries.end(); ++it ){
+ if(it.key()){
+ Interface *i = (it.key())->addNewInterface(item->text(0));
+ if(i){
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ }
+ }
+ }
}
@@ -155,8 +170,9 @@ void MainWindowImp::removeClicked(){ QListViewItem *item = connectionList->currentItem();
- if(item == NULL) {
- QMessageBox::information(this, "Error","Please select an interface.", "Ok");
- return;
+ if(!item) {
+ QMessageBox::information(this, "Error","Please select an interface.", "Ok");
+ return;
}
- if((interfaceItems[item])->getModuleOwner() == NULL){
+ Interface *i = interfaceItems[item];
+ if(i->getModuleOwner() == NULL){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
@@ -164,5 +180,10 @@ void MainWindowImp::removeClicked(){ else{
- // Try to remove.
+ 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?
+ }
}
-
}
@@ -313,3 +334,4 @@ void MainWindowImp::jobDone(KProcess *process){ /**
- *
+ * Update this interface. If no QListViewItem exists create one.
+ * @param Interface* pointer to the interface that needs to be updated.
*/
@@ -318,3 +340,3 @@ void MainWindowImp::updateInterface(Interface *i){ - // See if we already have it
+ // Find the interface, making it if needed.
if(items.find(i) == items.end()){
@@ -327,3 +349,2 @@ void MainWindowImp::updateInterface(Interface *i){ }
-
items.insert(i, item);
@@ -333,8 +354,5 @@ void MainWindowImp::updateInterface(Interface *i){ item = items[i];
-
- QString statusImage = "down";
- if(i->getStatus())
- statusImage = "up";
- QPixmap status = (Resource::loadPixmap(statusImage));
- item->setPixmap(0, status);
+
+ // Update the icons and information
+ item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
@@ -348,10 +366,8 @@ void MainWindowImp::updateInterface(Interface *i){ // Actually try to use the Module
- if(i->getModuleOwner() != NULL){
+ if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
- }
- QPixmap type = (Resource::loadPixmap(typeName));
- item->setPixmap(1, type);
-
- item->setText(2, i->getHardwareName());
+ item->setPixmap(1, (Resource::loadPixmap(typeName)));
+ item->setText(2, i->getHardwareName());
+ item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
}
@@ -361,8 +377,12 @@ void MainWindowImp::updateInterface(Interface *i){ * Don't add profiles that already exists.
- * Appends to the combo and QStringList
+ * Appends to the list and QStringList
*/
void MainWindowImp::addProfile(){
- QString newProfileName = "New";
+ NameDialog foo(this, "namedialog", true);
+ QString newProfileName = foo.go();
+ if(newProfileName.length() == 0)
+ return;
+
if(profiles.grep(newProfileName).count() > 0){
- QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
+ QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
return;
@@ -371,3 +391,2 @@ void MainWindowImp::addProfile(){ profilesList->insertItem(newProfileName);
-
}
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro index ba70180..e146eb4 100644 --- a/noncore/settings/networksettings/networksetup.pro +++ b/noncore/settings/networksettings/networksetup.pro @@ -3,4 +3,4 @@ TEMPLATE = app CONFIG = qt warn_on release -HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h -SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp +HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h namedialog.h +SOURCES = main.cpp namedialog.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp #INCLUDEPATH += $(QPEDIR)/include |