summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO1
-rw-r--r--noncore/net/networksetup/interfaces.cpp26
-rw-r--r--noncore/net/networksetup/interfaces.h3
-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.h3
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp22
-rw-r--r--noncore/settings/networksettings/networksetup.pro6
10 files changed, 106 insertions, 10 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
@@ -1,7 +1,8 @@
[ ] 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/interfaces.cpp b/noncore/net/networksetup/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/net/networksetup/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces.cpp
@@ -31,28 +31,52 @@ Interfaces::Interfaces(QString useInterfacesFile){
QString line;
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
+
+/**
+ * Get a list of all interfaces in the interface file. Usefull for
+ * hardware that is not currently connected such as an 802.11b card
+ * not plugged in, but configured for when it is plugged in.
+ * @return Return string list of interfaces.
+ **/
+QStringList Interfaces::getInterfaceList(){
+ QStringList list;
+ for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
+ QString line = (*it).simplifyWhiteSpace();
+ if(line.contains(IFACE)){
+ line = 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)
qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
if(awi.count() < 1)
return false;
return true;
}
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
@@ -14,25 +14,26 @@
#define INTERFACES_METHOD_STATIC "static"
#define INTERFACES_METHOD_PPP "ppp"
/**
* This class provides a clean frontend for parsing the network interfaces file.
* It provides helper functions to minipulate the options within the file.
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
-
+ QStringList getInterfaceList();
+
bool isAuto(QString interface);
bool setAuto(QString interface, bool setAuto);
bool removeInterface();
bool addInterface(QString interface, QString family, QString method);
bool 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);
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,16 +1,18 @@
#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>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
@@ -323,24 +325,41 @@ void MainWindowImp::jobDone(KProcess *process){
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
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.
*/
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
@@ -357,24 +376,27 @@ void MainWindowImp::updateInterface(Interface *i){
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->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(""));
}
void MainWindowImp::newProfileChanged(const QString& newText){
if(newText.length() > 0)
newProfileButton->setEnabled(true);
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
@@ -1,7 +1,8 @@
[ ] 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/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp
index b8a3e7f..1287d90 100644
--- a/noncore/settings/networksettings/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces.cpp
@@ -31,28 +31,52 @@ Interfaces::Interfaces(QString useInterfacesFile){
QString line;
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
+
+/**
+ * Get a list of all interfaces in the interface file. Usefull for
+ * hardware that is not currently connected such as an 802.11b card
+ * not plugged in, but configured for when it is plugged in.
+ * @return Return string list of interfaces.
+ **/
+QStringList Interfaces::getInterfaceList(){
+ QStringList list;
+ for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
+ QString line = (*it).simplifyWhiteSpace();
+ if(line.contains(IFACE)){
+ line = 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)
qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
if(awi.count() < 1)
return false;
return true;
}
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
@@ -14,25 +14,26 @@
#define INTERFACES_METHOD_STATIC "static"
#define INTERFACES_METHOD_PPP "ppp"
/**
* This class provides a clean frontend for parsing the network interfaces file.
* It provides helper functions to minipulate the options within the file.
* See the interfaces man page for the syntax rules.
*/
class Interfaces {
public:
Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
-
+ QStringList getInterfaceList();
+
bool isAuto(QString interface);
bool setAuto(QString interface, bool setAuto);
bool removeInterface();
bool addInterface(QString interface, QString family, QString method);
bool 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);
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,16 +1,18 @@
#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>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
@@ -323,24 +325,41 @@ void MainWindowImp::jobDone(KProcess *process){
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
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.
*/
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
@@ -357,24 +376,27 @@ void MainWindowImp::updateInterface(Interface *i){
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->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(""));
}
void MainWindowImp::newProfileChanged(const QString& newText){
if(newText.length() > 0)
newProfileButton->setEnabled(true);
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