summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interface.cpp16
-rw-r--r--noncore/net/networksetup/interface.h4
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp7
-rw-r--r--noncore/settings/networksettings/interface.cpp16
-rw-r--r--noncore/settings/networksettings/interface.h4
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp7
6 files changed, 26 insertions, 28 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index 1e01da4..a84b91f 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -2,25 +2,25 @@
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#define IFCONFIG "/sbin/ifconfig"
#define HDCP_INFO_DIR "/etc/dhcpc"
#include <stdio.h>
#include <stdlib.h>
-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){
+Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("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();
@@ -34,65 +34,65 @@ 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){
- hardareName = 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)
return;
- int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
+ int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
if(ret != 0)
return;
status = true;
refresh();
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
if(false == status)
return;
- int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
+ int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
if(ret != 0)
return;
status = true;
refresh();
}
/**
* Try to restart the interface.
*/
void Interface::restart(){
stop();
@@ -110,26 +110,26 @@ bool Interface::refresh(){
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(interfaceName);
- int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
+ 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());
if(ret != 0){
qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
return false;
}
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
// Set to the defaults
@@ -168,25 +168,25 @@ bool Interface::refresh(){
// reset DHCP info
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
dhcp = false;
QString dhcpDirectory(HDCP_INFO_DIR);
QDir d(dhcpDirectory);
if(!d.exists(dhcpDirectory))
dhcpDirectory = "/var/run";
// See if we have
- QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
+ QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
emit(updateInterface(this));
return true;
}
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
@@ -200,25 +200,25 @@ bool Interface::refresh(){
if(line.contains("DHCPSIADDR="))
dhcpServerIp = line.mid(11, line.length());
if(line.contains("LEASETIME="))
leaseTime = line.mid(10, line.length()).toInt();
if(line.contains("RENEWALTIME="))
renewalTime = line.mid(12, line.length()).toInt();
}
file.close();
//qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
//qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
// Get the pid of the deamond
- dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
+ dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
int pid = -1;
stream.setDevice( &file );
while ( !stream.eof() ) {
line = stream.readLine();
pid = line.toInt();
}
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
index 980171a..7943fd6 100644
--- a/noncore/net/networksetup/interface.h
+++ b/noncore/net/networksetup/interface.h
@@ -15,25 +15,25 @@ signals:
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 hardareName; };
+ 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; };
@@ -42,25 +42,25 @@ public:
public slots:
bool refresh();
void start();
void stop();
void restart();
private:
// Interface information
bool status;
bool attached;
QString interfaceName;
- QString hardareName;
+ QString hardwareName;
Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 117bac1..a446d29 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -299,47 +299,46 @@ void MainWindowImp::jobDone(KProcess *process){
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
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)
+ if(fileName == TEMP_ALL)
i = new Interface(this, interfaceName, false);
else
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];
if(fileName != TEMP_ALL)
- i->setStatus(true);
+ (interfaceNames[interfaceName])->setStatus(true);
}
}
}
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 ) {
bool found = false;
@@ -389,25 +388,25 @@ void MainWindowImp::updateInterface(Interface *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->getInterfaceName().contains("usb"))
typeName = "usb";
-
+
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){
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index 1e01da4..a84b91f 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -2,25 +2,25 @@
#include <qdatetime.h>
#include <qfile.h>
#include <qdir.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#define IFCONFIG "/sbin/ifconfig"
#define HDCP_INFO_DIR "/etc/dhcpc"
#include <stdio.h>
#include <stdlib.h>
-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){
+Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("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();
@@ -34,65 +34,65 @@ 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){
- hardareName = 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)
return;
- int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
+ int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1());
// See if it was successfull...
if(ret != 0)
return;
status = true;
refresh();
}
/**
* Try to stop the interface.
*/
void Interface::stop(){
// check to see if we are already stopped.
if(false == status)
return;
- int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
+ int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1());
if(ret != 0)
return;
status = true;
refresh();
}
/**
* Try to restart the interface.
*/
void Interface::restart(){
stop();
@@ -110,26 +110,26 @@ bool Interface::refresh(){
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(interfaceName);
- int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
+ 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());
if(ret != 0){
qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
return false;
}
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
// Set to the defaults
@@ -168,25 +168,25 @@ bool Interface::refresh(){
// reset DHCP info
dhcpServerIp = "";
leaseObtained = "";
leaseExpires = "";
dhcp = false;
QString dhcpDirectory(HDCP_INFO_DIR);
QDir d(dhcpDirectory);
if(!d.exists(dhcpDirectory))
dhcpDirectory = "/var/run";
// See if we have
- QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
+ QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name()));
// If there is no DHCP information then exit now with no errors.
if(!QFile::exists(dhcpFile)){
emit(updateInterface(this));
return true;
}
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
@@ -200,25 +200,25 @@ bool Interface::refresh(){
if(line.contains("DHCPSIADDR="))
dhcpServerIp = line.mid(11, line.length());
if(line.contains("LEASETIME="))
leaseTime = line.mid(10, line.length()).toInt();
if(line.contains("RENEWALTIME="))
renewalTime = line.mid(12, line.length()).toInt();
}
file.close();
//qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
//qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
// Get the pid of the deamond
- dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
+ dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name()));
file.setName(dhcpFile);
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
return false;
}
int pid = -1;
stream.setDevice( &file );
while ( !stream.eof() ) {
line = stream.readLine();
pid = line.toInt();
}
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
index 980171a..7943fd6 100644
--- a/noncore/settings/networksettings/interface.h
+++ b/noncore/settings/networksettings/interface.h
@@ -15,25 +15,25 @@ signals:
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 hardareName; };
+ 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; };
@@ -42,25 +42,25 @@ public:
public slots:
bool refresh();
void start();
void stop();
void restart();
private:
// Interface information
bool status;
bool attached;
QString interfaceName;
- QString hardareName;
+ QString hardwareName;
Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 117bac1..a446d29 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -299,47 +299,46 @@ void MainWindowImp::jobDone(KProcess *process){
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
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)
+ if(fileName == TEMP_ALL)
i = new Interface(this, interfaceName, false);
else
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];
if(fileName != TEMP_ALL)
- i->setStatus(true);
+ (interfaceNames[interfaceName])->setStatus(true);
}
}
}
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 ) {
bool found = false;
@@ -389,25 +388,25 @@ void MainWindowImp::updateInterface(Interface *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->getInterfaceName().contains("usb"))
typeName = "usb";
-
+
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){