summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interfaces/interface.cpp24
-rw-r--r--noncore/net/networksetup/interfaces/interface.h3
-rw-r--r--noncore/net/networksetup/interfaces/interfaceinformationimp.cpp13
-rw-r--r--noncore/net/networksetup/interfaces/interfaceinformationimp.h1
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.pro2
-rw-r--r--noncore/settings/networksettings/interfaces/interface.cpp24
-rw-r--r--noncore/settings/networksettings/interfaces/interface.h3
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp13
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.h1
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.pro2
10 files changed, 66 insertions, 20 deletions
diff --git a/noncore/net/networksetup/interfaces/interface.cpp b/noncore/net/networksetup/interfaces/interface.cpp
index 929b3a1..e4f405e 100644
--- a/noncore/net/networksetup/interfaces/interface.cpp
+++ b/noncore/net/networksetup/interfaces/interface.cpp
@@ -58,42 +58,52 @@ void Interface::setModuleOwner(Module *owner){
};
/**
* Try to start the interface.
*/
void Interface::start(){
// check to see if we are already running.
- if(true == status)
+ if(true == status){
+ emit (updateMessage("Unable to start interface,\n already started"));
return;
-
+ }
+
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
- if(ret != 0)
+ if(ret != 0){
+ emit (updateMessage("Starting interface failed."));
return;
-
+ }
+
status = true;
refresh();
+ emit (updateMessage("Start successfull"));
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
- if(false == status)
+ if(false == status){
+ emit (updateMessage("Unable to stop interface,\n already stopped"));
return;
+ }
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
- if(ret != 0)
+ if(ret != 0){
+ emit (updateMessage("Stopping interface failed."));
return;
+ }
- status = true;
+ status = false;
refresh();
+ emit (updateMessage("Stop successfull"));
}
/**
* Try to restart the interface.
*/
void Interface::restart(){
stop();
start();
diff --git a/noncore/net/networksetup/interfaces/interface.h b/noncore/net/networksetup/interfaces/interface.h
index dc9c6d3..fc064fe 100644
--- a/noncore/net/networksetup/interfaces/interface.h
+++ b/noncore/net/networksetup/interfaces/interface.h
@@ -6,17 +6,18 @@
class Module;
class Interface : public QObject{
Q_OBJECT
signals:
void updateInterface(Interface *i);
-
+ void updateMessage(const QString &message);
+
public:
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 newStatus);
diff --git a/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp b/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp
index 43483fb..39575c4 100644
--- a/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp
+++ b/noncore/net/networksetup/interfaces/interfaceinformationimp.cpp
@@ -1,32 +1,34 @@
#include "interfaceinformationimp.h"
#include "interfaceadvanced.h"
#include <qpushbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
+#include <qmessagebox.h>
+
#include <assert.h>
/**
* Constructor for the InterfaceInformationImp class. This class pretty much
* just display's information about the interface that is passed to it.
*/
InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
assert(i);
interface = i;
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
+ connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
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()));
-
}
/**
* 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){
@@ -61,10 +63,19 @@ void InterfaceInformationImp::advanced(){
a->leaseObtainedLabel->setText(interface->getLeaseObtained());
a->leaseExpiresLabel->setText(interface->getLeaseExpires());
a->dhcpInformation->setEnabled(interface->isDhcp());
a->showMaximized();
a->show();
}
+/**
+ * Messages from the interface if start/stop went as planned.
+ * Purly for user feedback.
+ * @param message the message to display.
+ */
+void InterfaceInformationImp::showMessage(const QString &message){
+ QMessageBox::information(this, "Message", message, QMessageBox::Ok);
+}
+
// infoimp.cpp
diff --git a/noncore/net/networksetup/interfaces/interfaceinformationimp.h b/noncore/net/networksetup/interfaces/interfaceinformationimp.h
index 42213cc..65cdfe0 100644
--- a/noncore/net/networksetup/interfaces/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaces/interfaceinformationimp.h
@@ -10,16 +10,17 @@ Q_OBJECT
public:
InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
~InterfaceInformationImp(){};
private slots:
void advanced();
void updateInterface(Interface *i);
+ void showMessage(const QString &message);
private:
Interface *interface;
};
#endif
diff --git a/noncore/net/networksetup/interfaces/interfaces.pro b/noncore/net/networksetup/interfaces/interfaces.pro
index 9a024f6..d6b43fb 100644
--- a/noncore/net/networksetup/interfaces/interfaces.pro
+++ b/noncore/net/networksetup/interfaces/interfaces.pro
@@ -1,12 +1,12 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#CONFIG += qt warn_on debug
-DESTDIR = $(QTDIR)/lib$(PROJMAK)
+#DESTDIR = $(QTDIR)/lib$(PROJMAK)
HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h
SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp
INCLUDEPATH += $(OPIEDIR)/include ../
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui
TARGET = interfaces
VERSION = 1.0.0
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp
index 929b3a1..e4f405e 100644
--- a/noncore/settings/networksettings/interfaces/interface.cpp
+++ b/noncore/settings/networksettings/interfaces/interface.cpp
@@ -58,42 +58,52 @@ void Interface::setModuleOwner(Module *owner){
};
/**
* Try to start the interface.
*/
void Interface::start(){
// check to see if we are already running.
- if(true == status)
+ if(true == status){
+ emit (updateMessage("Unable to start interface,\n already started"));
return;
-
+ }
+
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
- if(ret != 0)
+ if(ret != 0){
+ emit (updateMessage("Starting interface failed."));
return;
-
+ }
+
status = true;
refresh();
+ emit (updateMessage("Start successfull"));
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
- if(false == status)
+ if(false == status){
+ emit (updateMessage("Unable to stop interface,\n already stopped"));
return;
+ }
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
- if(ret != 0)
+ if(ret != 0){
+ emit (updateMessage("Stopping interface failed."));
return;
+ }
- status = true;
+ status = false;
refresh();
+ emit (updateMessage("Stop successfull"));
}
/**
* Try to restart the interface.
*/
void Interface::restart(){
stop();
start();
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h
index dc9c6d3..fc064fe 100644
--- a/noncore/settings/networksettings/interfaces/interface.h
+++ b/noncore/settings/networksettings/interfaces/interface.h
@@ -6,17 +6,18 @@
class Module;
class Interface : public QObject{
Q_OBJECT
signals:
void updateInterface(Interface *i);
-
+ void updateMessage(const QString &message);
+
public:
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 newStatus);
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index 43483fb..39575c4 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,32 +1,34 @@
#include "interfaceinformationimp.h"
#include "interfaceadvanced.h"
#include <qpushbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
+#include <qmessagebox.h>
+
#include <assert.h>
/**
* Constructor for the InterfaceInformationImp class. This class pretty much
* just display's information about the interface that is passed to it.
*/
InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f){
assert(i);
interface = i;
connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
+ connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
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()));
-
}
/**
* 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){
@@ -61,10 +63,19 @@ void InterfaceInformationImp::advanced(){
a->leaseObtainedLabel->setText(interface->getLeaseObtained());
a->leaseExpiresLabel->setText(interface->getLeaseExpires());
a->dhcpInformation->setEnabled(interface->isDhcp());
a->showMaximized();
a->show();
}
+/**
+ * Messages from the interface if start/stop went as planned.
+ * Purly for user feedback.
+ * @param message the message to display.
+ */
+void InterfaceInformationImp::showMessage(const QString &message){
+ QMessageBox::information(this, "Message", message, QMessageBox::Ok);
+}
+
// infoimp.cpp
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
index 42213cc..65cdfe0 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
@@ -10,16 +10,17 @@ Q_OBJECT
public:
InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
~InterfaceInformationImp(){};
private slots:
void advanced();
void updateInterface(Interface *i);
+ void showMessage(const QString &message);
private:
Interface *interface;
};
#endif
diff --git a/noncore/settings/networksettings/interfaces/interfaces.pro b/noncore/settings/networksettings/interfaces/interfaces.pro
index 9a024f6..d6b43fb 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.pro
+++ b/noncore/settings/networksettings/interfaces/interfaces.pro
@@ -1,12 +1,12 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#CONFIG += qt warn_on debug
-DESTDIR = $(QTDIR)/lib$(PROJMAK)
+#DESTDIR = $(QTDIR)/lib$(PROJMAK)
HEADERS = interface.h interfaceinformationimp.h interfaces.h interfacesetupimp.h
SOURCES = interface.cpp interfaces.cpp interfaceinformationimp.cpp interfacesetupimp.cpp
INCLUDEPATH += $(OPIEDIR)/include ../
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = interfaceadvanced.ui interfaceinformation.ui interfacesetup.ui
TARGET = interfaces
VERSION = 1.0.0