summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interface.cpp
authorbenmeyer <benmeyer>2002-10-17 16:30:44 (UTC)
committer benmeyer <benmeyer>2002-10-17 16:30:44 (UTC)
commit18cc7321db186865629a5c4702074211e42b92fd (patch) (side-by-side diff)
treebeb15112009c1cc966115904a322b32d465e47e6 /noncore/settings/networksettings/interface.cpp
parent75f078ec92376db2c90a327bbc50d9bb5c1fb57a (diff)
downloadopie-18cc7321db186865629a5c4702074211e42b92fd.zip
opie-18cc7321db186865629a5c4702074211e42b92fd.tar.gz
opie-18cc7321db186865629a5c4702074211e42b92fd.tar.bz2
interface is now a qobject
Diffstat (limited to 'noncore/settings/networksettings/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interface.cpp77
1 files changed, 61 insertions, 16 deletions
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
@@ -11,51 +11,92 @@
#include <stdio.h>
#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();
}
/**
@@ -74,6 +115,7 @@ bool Interface::refresh(){
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
+ emit(updateInterface(this));
return true;
}
@@ -138,6 +180,7 @@ bool Interface::refresh(){
QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
+ emit(updateInterface(this));
return true;
}
@@ -235,6 +278,8 @@ bool Interface::refresh(){
leaseExpires = datetime.toString();
dhcp = true;
+
+ emit(updateInterface(this));
return true;
}