summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/TODO2
-rw-r--r--noncore/net/networksetup/interface.cpp77
-rw-r--r--noncore/net/networksetup/interface.h31
-rw-r--r--noncore/net/networksetup/interfaceadvanced.ui11
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.cpp51
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h6
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp43
-rw-r--r--noncore/net/networksetup/wlan/wlanmodule.cpp4
-rw-r--r--noncore/settings/networksettings/TODO2
-rw-r--r--noncore/settings/networksettings/interface.cpp77
-rw-r--r--noncore/settings/networksettings/interface.h31
-rw-r--r--noncore/settings/networksettings/interfaceadvanced.ui11
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.cpp51
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h6
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp43
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp4
16 files changed, 258 insertions, 192 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO
index 7386646..c8e2989 100644
--- a/noncore/net/networksetup/TODO
+++ b/noncore/net/networksetup/TODO
@@ -1,2 +1,4 @@
+Write a class that parses /proc and not ifconfig
+
[ ] Wlanmodule needs to check if an interface supports wireless
extensions.
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -12,49 +12,90 @@
#include <stdlib.h>
-Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
+Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
refresh();
}
/**
+ * Set status
+ * @param newStatus - the new status
+ * emit updateInterface
+ */
+void Interface::setStatus(bool newStatus){
+ if(status != newStatus){
+ status = newStatus;
+ refresh();
+ }
+};
+
+/**
+ * Set if attached or not (802.11 card pulled out for example)
+ * @param isAttached - if attached
+ * emit updateInterface
+ */
+void Interface::setAttached(bool isAttached){
+ attached = isAttached;
+ emit(updateInterface(this));
+};
+
+/**
+ * Set Hardware name
+ * @param name - the new name
+ * emit updateInterface
+ */
+void Interface::setHardwareName(QString name){
+ hardareName = name;
+ emit(updateInterface(this));
+};
+
+/**
+ * Set Module owner
+ * @param owner - the new owner
+ * emit updateInterface
+ */
+void Interface::setModuleOwner(Module *owner){
+ moduleOwner = owner;
+ emit(updateInterface(this));
+};
+
+
+/**
* Try to start the interface.
- * @return bool true if successfull.
*/
-bool Interface::start(){
+void Interface::start(){
// check to see if we are already running.
- if(status)
- return false;
+ if(true == status)
+ return;
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
+ // See if it was successfull...
if(ret != 0)
- return false;
+ return;
status = true;
refresh();
- return true;
}
/**
* Try to stop the interface.
- * @return bool true if successfull.
*/
-bool Interface::stop(){
+void Interface::stop(){
// check to see if we are already stopped.
- if(status == false)
- return false;
+ if(false == status)
+ return;
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
- return false;
+ return;
status = true;
refresh();
- return true;
}
+
/**
* Try to restart the interface.
- * @return bool true if successfull.
*/
-bool Interface::restart(){
- return (stop() && start());
+void Interface::restart(){
+ stop();
+ start();
}
@@ -75,4 +116,5 @@ bool Interface::refresh(){
leaseObtained = "";
leaseExpires = "";
+ emit(updateInterface(this));
return true;
}
@@ -139,4 +181,5 @@ bool Interface::refresh(){
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
+ emit(updateInterface(this));
return true;
}
@@ -236,4 +279,6 @@ bool Interface::refresh(){
dhcp = true;
+
+ emit(updateInterface(this));
return true;
}
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
index 1406e99..980171a 100644
--- a/noncore/net/networksetup/interface.h
+++ b/noncore/net/networksetup/interface.h
@@ -3,27 +3,31 @@
#include <qstring.h>
+#include <qobject.h>
class Module;
-class Interface {
+class Interface : public QObject{
+ Q_OBJECT
+signals:
+ void updateInterface(Interface *i);
+
public:
- Interface(QString name = "unknown", bool status = false);
+ Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
virtual ~Interface(){};
+ virtual QString getInterfaceName(){ QString n(this->name()); return n; };
+
virtual bool getStatus(){ return status; };
- virtual void setStatus(bool newSatus){ status = newSatus; refresh(); };
+ virtual void setStatus(bool newStatus);
virtual bool isAttached(){ return attached; };
- virtual void setAttached(bool isAttached=false){ attached = isAttached; };
-
- virtual QString getInterfaceName(){ return interfaceName; };
- virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
+ virtual void setAttached(bool isAttached=false);
virtual QString getHardwareName(){ return hardareName; };
- virtual void setHardwareName(QString name="Unknown"){ hardareName = name; };
+ virtual void setHardwareName(QString name="Unknown");
virtual Module* getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; };
+ virtual void setModuleOwner(Module *owner=NULL);
// inet information.
@@ -36,9 +40,10 @@ public:
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
-
+
+public slots:
bool refresh();
- bool start();
- bool stop();
- bool restart();
+ void start();
+ void stop();
+ void restart();
private:
diff --git a/noncore/net/networksetup/interfaceadvanced.ui b/noncore/net/networksetup/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/net/networksetup/interfaceadvanced.ui
+++ b/noncore/net/networksetup/interfaceadvanced.ui
@@ -12,9 +12,16 @@
<x>0</x>
<y>0</y>
- <width>188</width>
- <height>277</height>
+ <width>214</width>
+ <height>286</height>
</rect>
</property>
<property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>320</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property stdset="1">
<name>caption</name>
<string>Advanced Interface Information</string>
diff --git a/noncore/net/networksetup/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/net/networksetup/interfaceinformationimp.cpp
+++ b/noncore/net/networksetup/interfaceinformationimp.cpp
@@ -14,14 +14,20 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na
interface = i;
- updateInterface();
- connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
- connect(stopButton, SIGNAL(clicked()), this, SLOT(stop()));
- connect(restartButton, SIGNAL(clicked()), this, SLOT(restart()));
- connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
+ 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()));
}
-void InterfaceInformationImp::updateInterface(){
+/**
+ * Update the interface information and buttons.
+ * @param Intarface *i the interface to update (should be the one we already
+ * know about).
+ */
+void InterfaceInformationImp::updateInterface(Interface *i){
if(interface->getStatus()){
startButton->setEnabled(false);
@@ -41,37 +47,4 @@ void InterfaceInformationImp::updateInterface(){
/**
- * Start the interface. Update the information if successfull
- */
-void InterfaceInformationImp::start(){
- if(interface->start()){
- updateInterface();
- }
-}
-
-/**
- * Stop the interface.
- */
-void InterfaceInformationImp::stop(){
- if(interface->stop()){
- updateInterface();
- }
-}
-
-/***
- * Tell the interface to refresh its information.
- **/
-void InterfaceInformationImp::refresh(){
- if(interface->refresh())
- updateInterface();
-}
-
-void InterfaceInformationImp::restart(){
- if(interface->restart()){
- updateInterface();
- }
-}
-
-
-/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaceinformationimp.h
@@ -14,13 +14,9 @@ public:
private slots:
- void start();
- void stop();
- void refresh();
- void restart();
void advanced();
+ void updateInterface(Interface *i);
private:
Interface *interface;
- void updateInterface();
};
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -305,11 +305,27 @@ void MainWindowImp::jobDone(KProcess *process){
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(interfaceName, false);
+ i = new Interface(this, interfaceName, false);
else
- i = new Interface(interfaceName, true);
+ 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()));
+
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
+ // It was an interface we already had.
else{
i = interfaceNames[interfaceName];
@@ -317,19 +333,4 @@ void MainWindowImp::jobDone(KProcess *process){
i->setStatus(true);
}
-
- i->setAttached(true);
- i->setInterfaceName(interfaceName);
-
- 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()));
- // We have found an interface
- //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
- interfaceNames.insert(i->getInterfaceName(), i);
- updateInterface(i);
}
}
@@ -348,10 +349,10 @@ void MainWindowImp::jobDone(KProcess *process){
}
if(!found){
- Interface *i = new Interface(*ni, false);
+ Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
- i->setInterfaceName(*ni);
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
+ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
@@ -396,5 +397,7 @@ void MainWindowImp::updateInterface(Interface *i){
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
-
+ if(i->getInterfaceName().contains("usb"))
+ typeName = "usb";
+
if(!i->isAttached())
typeName = "connect_no";
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/net/networksetup/wlan/wlanmodule.cpp
+++ b/noncore/net/networksetup/wlan/wlanmodule.cpp
@@ -25,6 +25,8 @@ QString WLANModule::getPixmapName(Interface* ){
*/
bool WLANModule::isOwner(Interface *i){
- if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0")
+ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
+ i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
return true;
+ }
return false;
}
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO
index 7386646..c8e2989 100644
--- a/noncore/settings/networksettings/TODO
+++ b/noncore/settings/networksettings/TODO
@@ -1,2 +1,4 @@
+Write a class that parses /proc and not ifconfig
+
[ ] Wlanmodule needs to check if an interface supports wireless
extensions.
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index 1f32093..1e01da4 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -12,49 +12,90 @@
#include <stdlib.h>
-Interface::Interface(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
+Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
refresh();
}
/**
+ * Set status
+ * @param newStatus - the new status
+ * emit updateInterface
+ */
+void Interface::setStatus(bool newStatus){
+ if(status != newStatus){
+ status = newStatus;
+ refresh();
+ }
+};
+
+/**
+ * Set if attached or not (802.11 card pulled out for example)
+ * @param isAttached - if attached
+ * emit updateInterface
+ */
+void Interface::setAttached(bool isAttached){
+ attached = isAttached;
+ emit(updateInterface(this));
+};
+
+/**
+ * Set Hardware name
+ * @param name - the new name
+ * emit updateInterface
+ */
+void Interface::setHardwareName(QString name){
+ hardareName = name;
+ emit(updateInterface(this));
+};
+
+/**
+ * Set Module owner
+ * @param owner - the new owner
+ * emit updateInterface
+ */
+void Interface::setModuleOwner(Module *owner){
+ moduleOwner = owner;
+ emit(updateInterface(this));
+};
+
+
+/**
* Try to start the interface.
- * @return bool true if successfull.
*/
-bool Interface::start(){
+void Interface::start(){
// check to see if we are already running.
- if(status)
- return false;
+ if(true == status)
+ return;
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
+ // See if it was successfull...
if(ret != 0)
- return false;
+ return;
status = true;
refresh();
- return true;
}
/**
* Try to stop the interface.
- * @return bool true if successfull.
*/
-bool Interface::stop(){
+void Interface::stop(){
// check to see if we are already stopped.
- if(status == false)
- return false;
+ if(false == status)
+ return;
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
- return false;
+ return;
status = true;
refresh();
- return true;
}
+
/**
* Try to restart the interface.
- * @return bool true if successfull.
*/
-bool Interface::restart(){
- return (stop() && start());
+void Interface::restart(){
+ stop();
+ start();
}
@@ -75,4 +116,5 @@ bool Interface::refresh(){
leaseObtained = "";
leaseExpires = "";
+ emit(updateInterface(this));
return true;
}
@@ -139,4 +181,5 @@ bool Interface::refresh(){
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
+ emit(updateInterface(this));
return true;
}
@@ -236,4 +279,6 @@ bool Interface::refresh(){
dhcp = true;
+
+ emit(updateInterface(this));
return true;
}
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
index 1406e99..980171a 100644
--- a/noncore/settings/networksettings/interface.h
+++ b/noncore/settings/networksettings/interface.h
@@ -3,27 +3,31 @@
#include <qstring.h>
+#include <qobject.h>
class Module;
-class Interface {
+class Interface : public QObject{
+ Q_OBJECT
+signals:
+ void updateInterface(Interface *i);
+
public:
- Interface(QString name = "unknown", bool status = false);
+ Interface(QObject * parent=0, const char * name= "unknown", bool status = false);
virtual ~Interface(){};
+ virtual QString getInterfaceName(){ QString n(this->name()); return n; };
+
virtual bool getStatus(){ return status; };
- virtual void setStatus(bool newSatus){ status = newSatus; refresh(); };
+ virtual void setStatus(bool newStatus);
virtual bool isAttached(){ return attached; };
- virtual void setAttached(bool isAttached=false){ attached = isAttached; };
-
- virtual QString getInterfaceName(){ return interfaceName; };
- virtual void setInterfaceName(QString name="unknown"){ interfaceName = name; };
+ virtual void setAttached(bool isAttached=false);
virtual QString getHardwareName(){ return hardareName; };
- virtual void setHardwareName(QString name="Unknown"){ hardareName = name; };
+ virtual void setHardwareName(QString name="Unknown");
virtual Module* getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; };
+ virtual void setModuleOwner(Module *owner=NULL);
// inet information.
@@ -36,9 +40,10 @@ public:
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
-
+
+public slots:
bool refresh();
- bool start();
- bool stop();
- bool restart();
+ void start();
+ void stop();
+ void restart();
private:
diff --git a/noncore/settings/networksettings/interfaceadvanced.ui b/noncore/settings/networksettings/interfaceadvanced.ui
index 7520abe..efe67b0 100644
--- a/noncore/settings/networksettings/interfaceadvanced.ui
+++ b/noncore/settings/networksettings/interfaceadvanced.ui
@@ -12,9 +12,16 @@
<x>0</x>
<y>0</y>
- <width>188</width>
- <height>277</height>
+ <width>214</width>
+ <height>286</height>
</rect>
</property>
<property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>320</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property stdset="1">
<name>caption</name>
<string>Advanced Interface Information</string>
diff --git a/noncore/settings/networksettings/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaceinformationimp.cpp
index e37e0f8..59a6400 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaceinformationimp.cpp
@@ -14,14 +14,20 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na
interface = i;
- updateInterface();
- connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
- connect(stopButton, SIGNAL(clicked()), this, SLOT(stop()));
- connect(restartButton, SIGNAL(clicked()), this, SLOT(restart()));
- connect(refreshButton, SIGNAL(clicked()), this, SLOT(refresh()));
+ 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()));
}
-void InterfaceInformationImp::updateInterface(){
+/**
+ * Update the interface information and buttons.
+ * @param Intarface *i the interface to update (should be the one we already
+ * know about).
+ */
+void InterfaceInformationImp::updateInterface(Interface *i){
if(interface->getStatus()){
startButton->setEnabled(false);
@@ -41,37 +47,4 @@ void InterfaceInformationImp::updateInterface(){
/**
- * Start the interface. Update the information if successfull
- */
-void InterfaceInformationImp::start(){
- if(interface->start()){
- updateInterface();
- }
-}
-
-/**
- * Stop the interface.
- */
-void InterfaceInformationImp::stop(){
- if(interface->stop()){
- updateInterface();
- }
-}
-
-/***
- * Tell the interface to refresh its information.
- **/
-void InterfaceInformationImp::refresh(){
- if(interface->refresh())
- updateInterface();
-}
-
-void InterfaceInformationImp::restart(){
- if(interface->restart()){
- updateInterface();
- }
-}
-
-
-/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
index c8a478e..42213cc 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaceinformationimp.h
@@ -14,13 +14,9 @@ public:
private slots:
- void start();
- void stop();
- void refresh();
- void restart();
void advanced();
+ void updateInterface(Interface *i);
private:
Interface *interface;
- void updateInterface();
};
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index b46362f..117bac1 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -305,11 +305,27 @@ void MainWindowImp::jobDone(KProcess *process){
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(interfaceName, false);
+ i = new Interface(this, interfaceName, false);
else
- i = new Interface(interfaceName, true);
+ 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()));
+
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
+ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
+ // It was an interface we already had.
else{
i = interfaceNames[interfaceName];
@@ -317,19 +333,4 @@ void MainWindowImp::jobDone(KProcess *process){
i->setStatus(true);
}
-
- i->setAttached(true);
- i->setInterfaceName(interfaceName);
-
- 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()));
- // We have found an interface
- //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
- interfaceNames.insert(i->getInterfaceName(), i);
- updateInterface(i);
}
}
@@ -348,10 +349,10 @@ void MainWindowImp::jobDone(KProcess *process){
}
if(!found){
- Interface *i = new Interface(*ni, false);
+ Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
- i->setInterfaceName(*ni);
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
+ connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
}
}
@@ -396,5 +397,7 @@ void MainWindowImp::updateInterface(Interface *i){
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
-
+ if(i->getInterfaceName().contains("usb"))
+ typeName = "usb";
+
if(!i->isAttached())
typeName = "connect_no";
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 98d2eb6..f0394b4 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -25,6 +25,8 @@ QString WLANModule::getPixmapName(Interface* ){
*/
bool WLANModule::isOwner(Interface *i){
- if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0")
+ if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){
+ i->setHardwareName(QString("802.11b (%1)").arg(i->getInterfaceName()));
return true;
+ }
return false;
}