summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-17 15:03:35 (UTC)
committer benmeyer <benmeyer>2002-10-17 15:03:35 (UTC)
commit1fa7ebd9512ac0497c3ede198621899a10e961af (patch) (side-by-side diff)
tree45be4e45b5408f46c3f2e59b1241aebf9a9bf869
parent6c8ae3c8af454c87f5f467fe17cbdffe4c8f5494 (diff)
downloadopie-1fa7ebd9512ac0497c3ede198621899a10e961af.zip
opie-1fa7ebd9512ac0497c3ede198621899a10e961af.tar.gz
opie-1fa7ebd9512ac0497c3ede198621899a10e961af.tar.bz2
added interface listing
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO1
-rw-r--r--noncore/net/networksetup/interfaces.cpp26
-rw-r--r--noncore/net/networksetup/interfaces.h1
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp22
-rw-r--r--noncore/net/networksetup/networksetup.pro6
-rw-r--r--noncore/settings/networksettings/TODO1
-rw-r--r--noncore/settings/networksettings/interfaces.cpp26
-rw-r--r--noncore/settings/networksettings/interfaces.h1
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp22
-rw-r--r--noncore/settings/networksettings/networksetup.pro6
10 files changed, 104 insertions, 8 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 70d6717..7386646 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -2,6 +2,7 @@
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/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -37,16 +37,40 @@ Interfaces::Interfaces(QString useInterfacesFile){
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
+
+/**
+ * Get a list of all interfaces in the interface file. Usefull for
+ * hardware that is not currently connected such as an 802.11b card
+ * not plugged in, but configured for when it is plugged in.
+ * @return Return string list of interfaces.
+ **/
+QStringList Interfaces::getInterfaceList(){
+ QStringList list;
+ for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
+ QString line = (*it).simplifyWhiteSpace();
+ if(line.contains(IFACE)){
+ line = line.mid(QString(IFACE).length() +1, line.length());
+ line = line.simplifyWhiteSpace();
+ int findSpace = line.find(" ");
+ if( findSpace >= 0){
+ line = line.mid(0, findSpace);
+ list.append(line);
+ }
+ }
+ }
+ return list;
+}
+
/**
* Find out if interface is in an "auto" group or not.
* Report any duplicates such as eth0 being in two differnt auto's
- * @param
+ * @param interface interface to check to see if it is on or not.
* @return true is interface is in auto
*/
bool Interfaces::isAuto(QString interface){
QStringList autoLines = interfaces.grep(QRegExp(AUTO));
QStringList awi = autoLines.grep(QRegExp(interface));
if(awi.count() > 1)
diff --git a/noncore/net/networksetup/interfaces.h b/noncore/net/networksetup/interfaces.h
index 2cc9689..8b4788c 100644
--- a/noncore/net/networksetup/interfaces.h
+++ b/noncore/net/networksetup/interfaces.h
@@ -20,12 +20,13 @@
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
+ QStringList getInterfaceList();
bool isAuto(QString interface);
bool setAuto(QString interface, bool setAuto);
bool removeInterface();
bool addInterface(QString interface, QString family, QString method);
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 36f12e0..24af1ec 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,10 +1,12 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
+#include "interfaces.h"
+
#include "module.h"
#include "kprocess.h"
#include <qpushbutton.h>
#include <qtabwidget.h>
@@ -329,12 +331,29 @@ void MainWindowImp::jobDone(KProcess *process){
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
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 ) {
+ for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
+ if(it.key() == (*ni)){
+ Interface *i = new Interface(*ni, false);
+ i->setAttached(false);
+ i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setInterfaceName(*ni);
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ }
+ }
+ }
+ }
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
@@ -363,12 +382,15 @@ void MainWindowImp::updateInterface(Interface *i){
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
+
+ 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());
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro
index f09db93..441bbaa 100644
--- a/noncore/net/networksetup/networksetup.pro
+++ b/noncore/net/networksetup/networksetup.pro
@@ -1,11 +1,11 @@
-DESTDIR = $(OPIEDIR)/bin
+#DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
#CONFIG = qt warn_on debug
CONFIG = qt warn_on release
HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
+#INCLUDEPATH += $(OPIEDIR)/include
+#DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
TARGET = networksetup
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 70d6717..7386646 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -2,6 +2,7 @@
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/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -37,16 +37,40 @@ Interfaces::Interfaces(QString useInterfacesFile){
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
+
+/**
+ * Get a list of all interfaces in the interface file. Usefull for
+ * hardware that is not currently connected such as an 802.11b card
+ * not plugged in, but configured for when it is plugged in.
+ * @return Return string list of interfaces.
+ **/
+QStringList Interfaces::getInterfaceList(){
+ QStringList list;
+ for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
+ QString line = (*it).simplifyWhiteSpace();
+ if(line.contains(IFACE)){
+ line = line.mid(QString(IFACE).length() +1, line.length());
+ line = line.simplifyWhiteSpace();
+ int findSpace = line.find(" ");
+ if( findSpace >= 0){
+ line = line.mid(0, findSpace);
+ list.append(line);
+ }
+ }
+ }
+ return list;
+}
+
/**
* Find out if interface is in an "auto" group or not.
* Report any duplicates such as eth0 being in two differnt auto's
- * @param
+ * @param interface interface to check to see if it is on or not.
* @return true is interface is in auto
*/
bool Interfaces::isAuto(QString interface){
QStringList autoLines = interfaces.grep(QRegExp(AUTO));
QStringList awi = autoLines.grep(QRegExp(interface));
if(awi.count() > 1)
diff --git a/noncore/settings/networksettings/interfaces.h b/noncore/settings/networksettings/interfaces.h
index 2cc9689..8b4788c 100644
--- a/noncore/settings/networksettings/interfaces.h
+++ b/noncore/settings/networksettings/interfaces.h
@@ -20,12 +20,13 @@
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
+ QStringList getInterfaceList();
bool isAuto(QString interface);
bool setAuto(QString interface, bool setAuto);
bool removeInterface();
bool addInterface(QString interface, QString family, QString method);
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 36f12e0..24af1ec 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,10 +1,12 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
+#include "interfaces.h"
+
#include "module.h"
#include "kprocess.h"
#include <qpushbutton.h>
#include <qtabwidget.h>
@@ -329,12 +331,29 @@ void MainWindowImp::jobDone(KProcess *process){
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
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 ) {
+ for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
+ if(it.key() == (*ni)){
+ Interface *i = new Interface(*ni, false);
+ i->setAttached(false);
+ i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setInterfaceName(*ni);
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ }
+ }
+ }
+ }
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
@@ -363,12 +382,15 @@ void MainWindowImp::updateInterface(Interface *i){
if(i->getHardwareName().contains("Local Loopback"))
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
+
+ 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());
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro
index f09db93..441bbaa 100644
--- a/noncore/settings/networksettings/networksetup.pro
+++ b/noncore/settings/networksettings/networksetup.pro
@@ -1,11 +1,11 @@
-DESTDIR = $(OPIEDIR)/bin
+#DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
#CONFIG = qt warn_on debug
CONFIG = qt warn_on release
HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
+#INCLUDEPATH += $(OPIEDIR)/include
+#DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
TARGET = networksetup