summaryrefslogtreecommitdiff
path: root/noncore
authorbenmeyer <benmeyer>2002-11-04 15:17:58 (UTC)
committer benmeyer <benmeyer>2002-11-04 15:17:58 (UTC)
commit17a29825dcf56cb0e224848e71e24ee6a884890b (patch) (side-by-side diff)
tree91a7f024de51081800a13312dd1b16822d86c188 /noncore
parenta5f1f8a58a5a654503d72042b12f36ab30216a16 (diff)
downloadopie-17a29825dcf56cb0e224848e71e24ee6a884890b.zip
opie-17a29825dcf56cb0e224848e71e24ee6a884890b.tar.gz
opie-17a29825dcf56cb0e224848e71e24ee6a884890b.tar.bz2
Fix bug and gives more user feedback now
Diffstat (limited to 'noncore') (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
@@ -34,90 +34,100 @@ void Interface::setStatus(bool newStatus){
*/
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){
hardwareName = 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.
*/
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();
}
/**
* Try to refresh the information about the interface.
* First call ifconfig, then check the dhcp-info file
* @return bool true if successfull.
*/
bool Interface::refresh(){
// See if we are up.
if(status == false){
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
dhcp = false;
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
emit(updateInterface(this));
return true;
}
QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
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
@@ -1,46 +1,47 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
#include <qobject.h>
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);
virtual bool isAttached(){ return attached; };
virtual void setAttached(bool isAttached=false);
virtual QString getHardwareName(){ return hardwareName; };
virtual void setHardwareName(QString name="Unknown");
virtual Module* getModuleOwner(){ return moduleOwner; };
virtual void setModuleOwner(Module *owner=NULL);
// inet information.
QString getMacAddress(){ return macAddress; };
QString getIp(){ return ip; };
QString getSubnetMask(){ return subnetMask; };
QString getBroadcast(){ return broadcast; };
bool isDhcp(){ return dhcp; };
QString getDhcpServerIp(){ return dhcpServerIp; };
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
public slots:
bool refresh();
void start();
void stop();
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,70 +1,81 @@
#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){
if(interface->getStatus()){
startButton->setEnabled(false);
stopButton->setEnabled(true);
restartButton->setEnabled(true);
}
else{
startButton->setEnabled(true);
stopButton->setEnabled(false);
restartButton->setEnabled(false);
}
macAddressLabel->setText(interface->getMacAddress());
ipAddressLabel->setText(interface->getIp());
subnetMaskLabel->setText(interface->getSubnetMask());
broadcastLabel->setText(interface->getBroadcast());
}
/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
*/
void InterfaceInformationImp::advanced(){
InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
a->interfaceName->setText(interface->getInterfaceName());
a->macAddressLabel->setText(interface->getMacAddress());
a->ipAddressLabel->setText(interface->getIp());
a->subnetMaskLabel->setText(interface->getSubnetMask());
a->broadcastLabel->setText(interface->getBroadcast());
a->dhcpServerLabel->setText(interface->getDhcpServerIp());
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
@@ -1,27 +1,28 @@
#ifndef INTERFACEINFORMATIONIMP_H
#define INTERFACEINFORMATIONIMP_H
#include "interfaceinformation.h"
#include "interface.h"
class InterfaceInformationImp : public InterfaceInformation {
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
// addserviceimp.h
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
@@ -34,90 +34,100 @@ void Interface::setStatus(bool newStatus){
*/
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){
hardwareName = 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.
*/
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();
}
/**
* Try to refresh the information about the interface.
* First call ifconfig, then check the dhcp-info file
* @return bool true if successfull.
*/
bool Interface::refresh(){
// See if we are up.
if(status == false){
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
dhcp = false;
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
emit(updateInterface(this));
return true;
}
QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name());
int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1());
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
@@ -1,46 +1,47 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
#include <qobject.h>
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);
virtual bool isAttached(){ return attached; };
virtual void setAttached(bool isAttached=false);
virtual QString getHardwareName(){ return hardwareName; };
virtual void setHardwareName(QString name="Unknown");
virtual Module* getModuleOwner(){ return moduleOwner; };
virtual void setModuleOwner(Module *owner=NULL);
// inet information.
QString getMacAddress(){ return macAddress; };
QString getIp(){ return ip; };
QString getSubnetMask(){ return subnetMask; };
QString getBroadcast(){ return broadcast; };
bool isDhcp(){ return dhcp; };
QString getDhcpServerIp(){ return dhcpServerIp; };
QString getLeaseObtained(){ return leaseObtained; };
QString getLeaseExpires(){ return leaseExpires; };
public slots:
bool refresh();
void start();
void stop();
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,70 +1,81 @@
#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){
if(interface->getStatus()){
startButton->setEnabled(false);
stopButton->setEnabled(true);
restartButton->setEnabled(true);
}
else{
startButton->setEnabled(true);
stopButton->setEnabled(false);
restartButton->setEnabled(false);
}
macAddressLabel->setText(interface->getMacAddress());
ipAddressLabel->setText(interface->getIp());
subnetMaskLabel->setText(interface->getSubnetMask());
broadcastLabel->setText(interface->getBroadcast());
}
/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
*/
void InterfaceInformationImp::advanced(){
InterfaceAdvanced *a = new InterfaceAdvanced(0, "InterfaceAdvanced");
a->interfaceName->setText(interface->getInterfaceName());
a->macAddressLabel->setText(interface->getMacAddress());
a->ipAddressLabel->setText(interface->getIp());
a->subnetMaskLabel->setText(interface->getSubnetMask());
a->broadcastLabel->setText(interface->getBroadcast());
a->dhcpServerLabel->setText(interface->getDhcpServerIp());
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
@@ -1,27 +1,28 @@
#ifndef INTERFACEINFORMATIONIMP_H
#define INTERFACEINFORMATIONIMP_H
#include "interfaceinformation.h"
#include "interface.h"
class InterfaceInformationImp : public InterfaceInformation {
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
// addserviceimp.h
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