summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interface.cpp2
-rw-r--r--noncore/net/networksetup/interface.h7
-rw-r--r--noncore/net/networksetup/interfacesetup.ui258
-rw-r--r--noncore/net/networksetup/mainwindow.ui74
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp59
-rw-r--r--noncore/net/networksetup/mainwindowimp.h1
-rw-r--r--noncore/net/networksetup/module.h7
-rw-r--r--noncore/net/networksetup/networksetup.pro4
-rw-r--r--noncore/settings/networksettings/interface.cpp2
-rw-r--r--noncore/settings/networksettings/interface.h7
-rw-r--r--noncore/settings/networksettings/interfacesetup.ui258
-rw-r--r--noncore/settings/networksettings/mainwindow.ui74
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp59
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h1
-rw-r--r--noncore/settings/networksettings/module.h7
-rw-r--r--noncore/settings/networksettings/networksetup.pro4
16 files changed, 530 insertions, 294 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index f6eed00..5b21364 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -1,109 +1,109 @@
#include "interface.h"
#include <qdatetime.h>
#include <qfile.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(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner("Default"), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
+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){
refresh();
}
/**
* Try to start the interface.
* @return bool true if successfull.
*/
bool Interface::start(){
// check to see if we are already running.
if(status)
return false;
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
return false;
status = true;
refresh();
return true;
}
/**
* Try to stop the interface.
* @return bool true if successfull.
*/
bool Interface::stop(){
// check to see if we are already stopped.
if(status == false)
return false;
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
return false;
status = true;
refresh();
return true;
}
/**
* Try to restart the interface.
* @return bool true if successfull.
*/
bool Interface::restart(){
return (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 = "";
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());
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
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
if(line.contains("HWaddr")){
int mac = line.find("HWaddr");
macAddress = line.mid(mac+7, line.length());
}
if(line.contains("inet addr")){
int ipl = line.find("inet addr");
int space = line.find(" ", ipl+10);
ip = line.mid(ipl+10, space-ipl-10);
diff --git a/noncore/net/networksetup/interface.h b/noncore/net/networksetup/interface.h
index 1ad71eb..5dc95a4 100644
--- a/noncore/net/networksetup/interface.h
+++ b/noncore/net/networksetup/interface.h
@@ -1,65 +1,66 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
+class Module;
class Interface {
public:
Interface(QString name = "unknown", bool status = false);
virtual ~Interface(){};
virtual bool getStatus(){ return status; };
virtual void setStatus(bool newSatus){ status = newSatus; refresh(); };
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 QString getHardwareName(){ return hardareName; };
virtual void setHardwareName(QString name="Unknown"){ hardareName = name; };
- virtual QString getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(QString owner="Default"){ moduleOwner = owner; };
+ virtual Module* getModuleOwner(){ return moduleOwner; };
+ virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; };
// 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; };
bool refresh();
bool start();
bool stop();
bool restart();
private:
// Interface information
bool status;
bool attached;
QString interfaceName;
QString hardareName;
- QString moduleOwner;
+ Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
};
#endif
// interface.h
diff --git a/noncore/net/networksetup/interfacesetup.ui b/noncore/net/networksetup/interfacesetup.ui
index ff9810e..d367608 100644
--- a/noncore/net/networksetup/interfacesetup.ui
+++ b/noncore/net/networksetup/interfacesetup.ui
@@ -1,284 +1,336 @@
<!DOCTYPE UI><UI>
<class>InterfaceSetup</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>InterfaceSetup</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>177</width>
- <height>320</height>
+ <width>271</width>
+ <height>280</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Configuration</string>
</property>
- <grid>
+ <vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="1" column="0" rowspan="1" colspan="2" >
- <class>Line</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Line1</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
- </property>
- </widget>
- <widget row="0" column="0" rowspan="1" colspan="2" >
+ <widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>autoStart</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Automaticly bring up</string>
</property>
</widget>
- <widget row="2" column="1" >
- <class>QComboBox</class>
- <item>
- <property>
- <name>text</name>
- <string>All</string>
- </property>
- </item>
+ <widget>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>profileCombo</cstring>
- </property>
- </widget>
- <widget row="4" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>leaseHoursLabel</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Requested Lease</string>
- </property>
- </widget>
- <widget row="3" column="0" rowspan="1" colspan="2" >
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>dhcpCheckBox</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>DHCP</string>
- </property>
- <property stdset="1">
- <name>checked</name>
- <bool>true</bool>
- </property>
- </widget>
- <widget row="2" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Profile:</string>
+ <cstring>Layout8</cstring>
</property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Profile</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>All</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>profileCombo</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer20</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
</widget>
- <widget row="4" column="1" >
- <class>QSpinBox</class>
+ <widget>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>leaseTime</cstring>
- </property>
- <property stdset="1">
- <name>suffix</name>
- <string> hours</string>
- </property>
- <property stdset="1">
- <name>maxValue</name>
- <number>336</number>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>24</number>
+ <cstring>Layout9</cstring>
</property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>dhcpCheckBox</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>DHCP</string>
+ </property>
+ <property stdset="1">
+ <name>checked</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>leaseHoursLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Requested Lease</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QSpinBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>leaseTime</cstring>
+ </property>
+ <property stdset="1">
+ <name>suffix</name>
+ <string> hours</string>
+ </property>
+ <property stdset="1">
+ <name>maxValue</name>
+ <number>336</number>
+ </property>
+ <property stdset="1">
+ <name>minValue</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>value</name>
+ <number>24</number>
+ </property>
+ </widget>
+ </hbox>
</widget>
- <spacer row="6" column="1" >
- <property>
- <name>name</name>
- <cstring>Spacer9</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
- </property>
- <property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget row="5" column="0" rowspan="1" colspan="2" >
+ <widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>staticGroupBox</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
<name>title</name>
<string>Static Ip Configuration</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="3" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>firstDNSLineEdit</cstring>
</property>
</widget>
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Subnet Mask</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>gatewayEdit</cstring>
</property>
</widget>
<widget row="1" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>subnetMaskEdit</cstring>
</property>
</widget>
<widget row="0" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>ipAddressEdit</cstring>
</property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>First DNS</string>
</property>
</widget>
<widget row="4" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>secondDNSLineEdit</cstring>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel4</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>IP Address</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Gateway</string>
</property>
</widget>
<widget row="4" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Second DNS</string>
</property>
</widget>
</grid>
</widget>
- </grid>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer9</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
</widget>
<connections>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseHoursLabel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseTime</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>staticGroupBox</receiver>
<slot>setDisabled(bool)</slot>
</connection>
</connections>
</UI>
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui
index c1fa101..a3f7bb1 100644
--- a/noncore/net/networksetup/mainwindow.ui
+++ b/noncore/net/networksetup/mainwindow.ui
@@ -1,326 +1,358 @@
<!DOCTYPE UI><UI>
<class>MainWindow</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>MainWindow</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>218</width>
+ <width>217</width>
<height>289</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Network Setup</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tabWidget</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Widget3</cstring>
</property>
<attribute>
<name>title</name>
<string>Interfaces</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>i</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<column>
<property>
<name>text</name>
<string>t</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<column>
<property>
<name>text</name>
<string>Name</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<property stdset="1">
<name>name</name>
<cstring>serviceList</cstring>
</property>
<property stdset="1">
<name>allColumnsShowFocus</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout2</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="1" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Add</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>informationServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Information</string>
</property>
</widget>
<widget row="0" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>configureServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Configure</string>
</property>
</widget>
<widget row="1" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removeServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Remove</string>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Profiles</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="0" column="0" rowspan="1" colspan="2" >
+ <widget row="1" column="0" rowspan="1" colspan="3" >
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Current Profile</string>
</property>
</widget>
- <widget row="0" column="2" >
+ <widget row="0" column="1" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>currentProfileLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string>All</string>
</property>
</widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
- <property stdset="1">
+ <spacer row="0" column="2" >
+ <property>
<name>name</name>
- <cstring>TextLabel1_2</cstring>
+ <cstring>Spacer2</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>Profiles</string>
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
- </widget>
- <spacer row="5" column="2" >
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="6" column="2" >
<property>
<name>name</name>
<cstring>Spacer16</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
- <widget row="2" column="0" rowspan="3" colspan="1" >
- <class>QListBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>profilesList</cstring>
- </property>
- </widget>
- <widget row="4" column="1" rowspan="1" colspan="2" >
+ <widget row="5" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton7</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Set Current</string>
</property>
</widget>
- <widget row="3" column="1" rowspan="1" colspan="2" >
+ <widget row="4" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removeProfileButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Remove</string>
</property>
</widget>
- <widget row="2" column="1" rowspan="1" colspan="2" >
+ <widget row="3" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>newProfileButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;New</string>
</property>
</widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Profiles</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" rowspan="3" colspan="2" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>profilesList</cstring>
+ </property>
+ </widget>
</grid>
</widget>
</widget>
</vbox>
</widget>
<customwidgets>
<customwidget>
<class>QWidget</class>
<header location="local">qwidget.h</header>
<sizehint>
<width>100</width>
<height>100</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>7</verdata>
</sizepolicy>
<pixmap>image0</pixmap>
</customwidget>
</customwidgets>
<images>
<image>
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
</image>
</images>
</UI>
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 0f48a4b..89dac6f 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -58,306 +58,339 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
getInterfaceList();
serviceList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
/**
* Deconstructor. Unload libraries and save profile list.
*/
MainWindowImp::~MainWindowImp(){
if(profiles.count() > 1){
Config cfg("NetworkSetup");
cfg.writeEntry("Profiles", profiles.join(" "));
}
}
void MainWindowImp::loadModules(QString path){
qDebug(path.latin1());
QDir d;
d.setPath(path);
if(!d.exists()){
qDebug("MainWindowImp:: Path doesn't exists");
return;
}
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
qDebug("Found");
Module *foo = loadPlugin(path + "/" + fi->fileName());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
qDebug(pluginFileName.latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
qDebug("MainWindowImp: Couldn't create object, but did load library!");
delete lib;
return NULL;
}
// Store for reference
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
// Now that we have a list of all of the protocals, list them.
{
QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
return;
}
AddServiceImp service(this, "AddService", true);
service.showMaximized();
service.exec();
}
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
void MainWindowImp::removeClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL) {
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if((interfaceItems[item])->getModuleOwner() == NULL){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
}
else{
// Try to remove.
}
}
/**
* See if there is a configuration for the selected protocal.
* Prompt with errors.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL){
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if((interfaceItems[item])->getModuleOwner() == NULL){
InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
conf->showMaximized();
conf->show();
}
else{
- InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
- conf->show();
+ QTabWidget *t = NULL;
+ QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t);
+ if(conf != NULL){
+ qDebug("Conf found");
+ if(t != NULL){
+ qDebug("Adding Interface");
+ InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true);
+ t->insertTab(i, "TCP/IP");
+ }
+ conf->showMaximized();
+ conf->show();
+ }
+ else{
+ InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true);
+ i->showMaximized();
+ i->show();
+ }
}
}
/**
* Pull up the information about the selected interface
* Report an error
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL){
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if( (interfaceItems[item])->getModuleOwner() == NULL){
InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
i->showMaximized();
i->show();
}
else{
- QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
- InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
- t->insertTab(i, "TCP/IP");
- t->show();
+ QTabWidget *t = NULL;
+ QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t);
+ if(conf != NULL){
+ if(t){
+ qDebug("Adding Interface");
+ InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
+ t->insertTab(i, "TCP/IP");
+ }
+ conf->showMaximized();
+ conf->show();
+ }
+ else{
+ InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true);
+ i->showMaximized();
+ i->show();
+ }
}
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
*/
void MainWindowImp::getInterfaceList(){
KShellProcess *processAll = new KShellProcess();
*processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
connect(processAll, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(processAll, TEMP_ALL);
processAll->start(KShellProcess::NotifyOnExit);
KShellProcess *process = new KShellProcess();
*process << "/sbin/ifconfig" << " > " TEMP_UP;
connect(process, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(process, TEMP_UP);
process->start(KShellProcess::NotifyOnExit);
}
void MainWindowImp::jobDone(KProcess *process){
QString fileName = threads[process];
threads.remove(process);
delete process;
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
return;
}
QTextStream stream( &file );
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;
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(interfaceName, false);
else
i = new Interface(interfaceName, true);
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
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);
}
}
file.close();
QFile::remove(fileName);
}
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// See if we already have it
if(items.find(i) == items.end()){
item = new QListViewItem(serviceList, "", "", "");
// See if you can't find a module owner for this interface
- //EmployeeMap::Iterator it;
- //for( it = map.begin(); it != map.end(); ++it )
- // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
-
+ QMap<Module*, QLibrary*>::Iterator it;
+ for( it = libraries.begin(); it != libraries.end(); ++it ){
+ if(it.key()->isOwner(i))
+ i->setModuleOwner(it.key());
+ }
+
items.insert(i, item);
interfaceItems.insert(item, i);
}
else
item = items[i];
QString statusImage = "down";
if(i->getStatus())
statusImage = "up";
QPixmap status = (Resource::loadPixmap(statusImage));
item->setPixmap(0, status);
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";
+ // Actually try to use the Module
+ if(i->getModuleOwner() != NULL){
+ typeName = i->getModuleOwner()->getPixmapName(i);
+ }
QPixmap type = (Resource::loadPixmap(typeName));
item->setPixmap(1, type);
item->setText(2, i->getHardwareName());
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the combo and QStringList
*/
void MainWindowImp::addProfile(){
QString newProfileName = "New";
if(profiles.grep(newProfileName).count() > 0){
QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
return;
}
QString profileToRemove = profilesList->currentText();
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(const QString& newProfile){
currentProfileLabel->setText(newProfile);
}
// mainwindowimp.cpp
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 8e300bf..19ebaf2 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -1,57 +1,56 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
#include <qmap.h>
#include <qstringlist.h>
class Module;
class Interface;
class QLibrary;
class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void jobDone(KProcess *process);
void getInterfaceList();
void addProfile();
void removeProfile();
void changeProfile(const QString&);
void updateInterface(Interface *i);
private:
void loadModules(QString path);
Module* loadPlugin(QString pluginFileName,
QString resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
- QMap<Interface*, Module*> modules;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
QStringList profiles;
};
#endif
// mainwindowimp.h
diff --git a/noncore/net/networksetup/module.h b/noncore/net/networksetup/module.h
index 13fd523..c1e9488 100644
--- a/noncore/net/networksetup/module.h
+++ b/noncore/net/networksetup/module.h
@@ -1,33 +1,34 @@
#ifndef NETCONF_MODULE_H
#define NETCONF_MODULE_H
#include <qobject.h>
#include <qlist.h>
#include <qmap.h>
#include "interface.h"
class QWidget;
+class QTabWidget;
class Module : QObject{
signals:
void updateInterface(Interface *i);
public:
Module(){};
virtual bool isOwner(Interface *){ return false; };
- virtual QWidget *configure(){ return NULL; } ;
- virtual QWidget *information(){ return NULL; };
+ virtual QWidget *configure(QTabWidget **tabWidget){ return NULL; } ;
+ virtual QWidget *information(QTabWidget **tabWidget){ return NULL; };
virtual QList<Interface> getInterfaces() = 0;
virtual QMap<QString, QString> possibleNewInterfaces() = 0;
virtual Interface *addNewInterface(QString name) = 0;
virtual bool remove(Interface* i) = 0;
-
+ virtual QString getPixmapName(Interface* i) = 0;
};
#endif
// module.h
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro
index a01b050..0d48790 100644
--- a/noncore/net/networksetup/networksetup.pro
+++ b/noncore/net/networksetup/networksetup.pro
@@ -1,10 +1,10 @@
TEMPLATE = app
-CONFIG = qt warn_on debug
-#CONFIG = qt warn_on release
+#CONFIG = qt warn_on debug
+CONFIG = qt warn_on release
HEADERS = mainwindowimp.h addserviceimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
SOURCES = main.cpp mainwindowimp.cpp addserviceimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
#INCLUDEPATH += $(QPEDIR)/include
#DEPENDPATH += $(QPEDIR)/include
LIBS += -lqpe
INTERFACES = mainwindow.ui addservice.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
TARGET = networksetup
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index f6eed00..5b21364 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -1,109 +1,109 @@
#include "interface.h"
#include <qdatetime.h>
#include <qfile.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(QString name, bool newSatus): status(newSatus), attached(false), interfaceName(name), hardareName("Unknown"), moduleOwner("Default"), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){
+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){
refresh();
}
/**
* Try to start the interface.
* @return bool true if successfull.
*/
bool Interface::start(){
// check to see if we are already running.
if(status)
return false;
int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
return false;
status = true;
refresh();
return true;
}
/**
* Try to stop the interface.
* @return bool true if successfull.
*/
bool Interface::stop(){
// check to see if we are already stopped.
if(status == false)
return false;
int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(interfaceName).latin1());
if(ret != 0)
return false;
status = true;
refresh();
return true;
}
/**
* Try to restart the interface.
* @return bool true if successfull.
*/
bool Interface::restart(){
return (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 = "";
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());
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
macAddress = "";
ip = "0.0.0.0";
subnetMask = "0.0.0.0";
broadcast = "";
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
if(line.contains("HWaddr")){
int mac = line.find("HWaddr");
macAddress = line.mid(mac+7, line.length());
}
if(line.contains("inet addr")){
int ipl = line.find("inet addr");
int space = line.find(" ", ipl+10);
ip = line.mid(ipl+10, space-ipl-10);
diff --git a/noncore/settings/networksettings/interface.h b/noncore/settings/networksettings/interface.h
index 1ad71eb..5dc95a4 100644
--- a/noncore/settings/networksettings/interface.h
+++ b/noncore/settings/networksettings/interface.h
@@ -1,65 +1,66 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include <qstring.h>
+class Module;
class Interface {
public:
Interface(QString name = "unknown", bool status = false);
virtual ~Interface(){};
virtual bool getStatus(){ return status; };
virtual void setStatus(bool newSatus){ status = newSatus; refresh(); };
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 QString getHardwareName(){ return hardareName; };
virtual void setHardwareName(QString name="Unknown"){ hardareName = name; };
- virtual QString getModuleOwner(){ return moduleOwner; };
- virtual void setModuleOwner(QString owner="Default"){ moduleOwner = owner; };
+ virtual Module* getModuleOwner(){ return moduleOwner; };
+ virtual void setModuleOwner(Module *owner=NULL){ moduleOwner = owner; };
// 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; };
bool refresh();
bool start();
bool stop();
bool restart();
private:
// Interface information
bool status;
bool attached;
QString interfaceName;
QString hardareName;
- QString moduleOwner;
+ Module *moduleOwner;
// Network information
QString macAddress;
QString ip;
QString broadcast;
QString subnetMask;
bool dhcp;
QString dhcpServerIp;
QString leaseObtained;
QString leaseExpires;
};
#endif
// interface.h
diff --git a/noncore/settings/networksettings/interfacesetup.ui b/noncore/settings/networksettings/interfacesetup.ui
index ff9810e..d367608 100644
--- a/noncore/settings/networksettings/interfacesetup.ui
+++ b/noncore/settings/networksettings/interfacesetup.ui
@@ -1,284 +1,336 @@
<!DOCTYPE UI><UI>
<class>InterfaceSetup</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>InterfaceSetup</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>177</width>
- <height>320</height>
+ <width>271</width>
+ <height>280</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Interface Configuration</string>
</property>
- <grid>
+ <vbox>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="1" column="0" rowspan="1" colspan="2" >
- <class>Line</class>
- <property stdset="1">
- <name>name</name>
- <cstring>Line1</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Horizontal</enum>
- </property>
- </widget>
- <widget row="0" column="0" rowspan="1" colspan="2" >
+ <widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>autoStart</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Automaticly bring up</string>
</property>
</widget>
- <widget row="2" column="1" >
- <class>QComboBox</class>
- <item>
- <property>
- <name>text</name>
- <string>All</string>
- </property>
- </item>
+ <widget>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>profileCombo</cstring>
- </property>
- </widget>
- <widget row="4" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>leaseHoursLabel</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Requested Lease</string>
- </property>
- </widget>
- <widget row="3" column="0" rowspan="1" colspan="2" >
- <class>QCheckBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>dhcpCheckBox</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>DHCP</string>
- </property>
- <property stdset="1">
- <name>checked</name>
- <bool>true</bool>
- </property>
- </widget>
- <widget row="2" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Profile:</string>
+ <cstring>Layout8</cstring>
</property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Profile</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <item>
+ <property>
+ <name>text</name>
+ <string>All</string>
+ </property>
+ </item>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>profileCombo</cstring>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer20</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
</widget>
- <widget row="4" column="1" >
- <class>QSpinBox</class>
+ <widget>
+ <class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
- <cstring>leaseTime</cstring>
- </property>
- <property stdset="1">
- <name>suffix</name>
- <string> hours</string>
- </property>
- <property stdset="1">
- <name>maxValue</name>
- <number>336</number>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>24</number>
+ <cstring>Layout9</cstring>
</property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>dhcpCheckBox</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>DHCP</string>
+ </property>
+ <property stdset="1">
+ <name>checked</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>leaseHoursLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Requested Lease</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QSpinBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>leaseTime</cstring>
+ </property>
+ <property stdset="1">
+ <name>suffix</name>
+ <string> hours</string>
+ </property>
+ <property stdset="1">
+ <name>maxValue</name>
+ <number>336</number>
+ </property>
+ <property stdset="1">
+ <name>minValue</name>
+ <number>1</number>
+ </property>
+ <property stdset="1">
+ <name>value</name>
+ <number>24</number>
+ </property>
+ </widget>
+ </hbox>
</widget>
- <spacer row="6" column="1" >
- <property>
- <name>name</name>
- <cstring>Spacer9</cstring>
- </property>
- <property stdset="1">
- <name>orientation</name>
- <enum>Vertical</enum>
- </property>
- <property stdset="1">
- <name>sizeType</name>
- <enum>Expanding</enum>
- </property>
- <property>
- <name>sizeHint</name>
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget row="5" column="0" rowspan="1" colspan="2" >
+ <widget>
<class>QGroupBox</class>
<property stdset="1">
<name>name</name>
<cstring>staticGroupBox</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
+ <name>frameShape</name>
+ <enum>Box</enum>
+ </property>
+ <property stdset="1">
+ <name>frameShadow</name>
+ <enum>Sunken</enum>
+ </property>
+ <property stdset="1">
<name>title</name>
<string>Static Ip Configuration</string>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="3" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>firstDNSLineEdit</cstring>
</property>
</widget>
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel5</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Subnet Mask</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>gatewayEdit</cstring>
</property>
</widget>
<widget row="1" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>subnetMaskEdit</cstring>
</property>
</widget>
<widget row="0" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>ipAddressEdit</cstring>
</property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>First DNS</string>
</property>
</widget>
<widget row="4" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>secondDNSLineEdit</cstring>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel4</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>IP Address</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Gateway</string>
</property>
</widget>
<widget row="4" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel3</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Second DNS</string>
</property>
</widget>
</grid>
</widget>
- </grid>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer9</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
</widget>
<connections>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseHoursLabel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>leaseTime</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>dhcpCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>staticGroupBox</receiver>
<slot>setDisabled(bool)</slot>
</connection>
</connections>
</UI>
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index c1fa101..a3f7bb1 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -1,326 +1,358 @@
<!DOCTYPE UI><UI>
<class>MainWindow</class>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>MainWindow</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>218</width>
+ <width>217</width>
<height>289</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Network Setup</string>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tabWidget</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Widget3</cstring>
</property>
<attribute>
<name>title</name>
<string>Interfaces</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>i</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<column>
<property>
<name>text</name>
<string>t</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<column>
<property>
<name>text</name>
<string>Name</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<property stdset="1">
<name>name</name>
<cstring>serviceList</cstring>
</property>
<property stdset="1">
<name>allColumnsShowFocus</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout2</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="1" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Add</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>informationServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Information</string>
</property>
</widget>
<widget row="0" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>configureServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Configure</string>
</property>
</widget>
<widget row="1" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removeServiceButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Remove</string>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Profiles</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
- <widget row="0" column="0" rowspan="1" colspan="2" >
+ <widget row="1" column="0" rowspan="1" colspan="3" >
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Current Profile</string>
</property>
</widget>
- <widget row="0" column="2" >
+ <widget row="0" column="1" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>currentProfileLabel</cstring>
</property>
<property stdset="1">
<name>frameShape</name>
<enum>Panel</enum>
</property>
<property stdset="1">
<name>frameShadow</name>
<enum>Sunken</enum>
</property>
<property stdset="1">
<name>text</name>
<string>All</string>
</property>
</widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
- <property stdset="1">
+ <spacer row="0" column="2" >
+ <property>
<name>name</name>
- <cstring>TextLabel1_2</cstring>
+ <cstring>Spacer2</cstring>
</property>
<property stdset="1">
- <name>text</name>
- <string>Profiles</string>
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
</property>
- </widget>
- <spacer row="5" column="2" >
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="6" column="2" >
<property>
<name>name</name>
<cstring>Spacer16</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
- <widget row="2" column="0" rowspan="3" colspan="1" >
- <class>QListBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>profilesList</cstring>
- </property>
- </widget>
- <widget row="4" column="1" rowspan="1" colspan="2" >
+ <widget row="5" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>PushButton7</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Set Current</string>
</property>
</widget>
- <widget row="3" column="1" rowspan="1" colspan="2" >
+ <widget row="4" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removeProfileButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Remove</string>
</property>
</widget>
- <widget row="2" column="1" rowspan="1" colspan="2" >
+ <widget row="3" column="2" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>newProfileButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;New</string>
</property>
</widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Profiles</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" rowspan="3" colspan="2" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>profilesList</cstring>
+ </property>
+ </widget>
</grid>
</widget>
</widget>
</vbox>
</widget>
<customwidgets>
<customwidget>
<class>QWidget</class>
<header location="local">qwidget.h</header>
<sizehint>
<width>100</width>
<height>100</height>
</sizehint>
<container>0</container>
<sizepolicy>
<hordata>7</hordata>
<verdata>7</verdata>
</sizepolicy>
<pixmap>image0</pixmap>
</customwidget>
</customwidgets>
<images>
<image>
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
</image>
</images>
</UI>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 0f48a4b..89dac6f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -58,306 +58,339 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
getInterfaceList();
serviceList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
/**
* Deconstructor. Unload libraries and save profile list.
*/
MainWindowImp::~MainWindowImp(){
if(profiles.count() > 1){
Config cfg("NetworkSetup");
cfg.writeEntry("Profiles", profiles.join(" "));
}
}
void MainWindowImp::loadModules(QString path){
qDebug(path.latin1());
QDir d;
d.setPath(path);
if(!d.exists()){
qDebug("MainWindowImp:: Path doesn't exists");
return;
}
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) ) {
if(fi->fileName().contains(".so")){
qDebug("Found");
Module *foo = loadPlugin(path + "/" + fi->fileName());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
qDebug(pluginFileName.latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL){
qDebug("MainWindowImp: Couldn't create object, but did load library!");
delete lib;
return NULL;
}
// Store for reference
libraries.insert(object, lib);
return object;
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked(){
// Now that we have a list of all of the protocals, list them.
{
QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
return;
}
AddServiceImp service(this, "AddService", true);
service.showMaximized();
service.exec();
}
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
void MainWindowImp::removeClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL) {
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if((interfaceItems[item])->getModuleOwner() == NULL){
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
}
else{
// Try to remove.
}
}
/**
* See if there is a configuration for the selected protocal.
* Prompt with errors.
*/
void MainWindowImp::configureClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL){
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if((interfaceItems[item])->getModuleOwner() == NULL){
InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
conf->showMaximized();
conf->show();
}
else{
- InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
- conf->show();
+ QTabWidget *t = NULL;
+ QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t);
+ if(conf != NULL){
+ qDebug("Conf found");
+ if(t != NULL){
+ qDebug("Adding Interface");
+ InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true);
+ t->insertTab(i, "TCP/IP");
+ }
+ conf->showMaximized();
+ conf->show();
+ }
+ else{
+ InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true);
+ i->showMaximized();
+ i->show();
+ }
}
}
/**
* Pull up the information about the selected interface
* Report an error
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = serviceList->currentItem();
if(item == NULL){
QMessageBox::information(this, "Error","Please select an interface.", "Ok");
return;
}
- if(modules.find(interfaceItems[item]) == modules.end()){
+ if( (interfaceItems[item])->getModuleOwner() == NULL){
InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
i->showMaximized();
i->show();
}
else{
- QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
- InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
- t->insertTab(i, "TCP/IP");
- t->show();
+ QTabWidget *t = NULL;
+ QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t);
+ if(conf != NULL){
+ if(t){
+ qDebug("Adding Interface");
+ InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
+ t->insertTab(i, "TCP/IP");
+ }
+ conf->showMaximized();
+ conf->show();
+ }
+ else{
+ InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true);
+ i->showMaximized();
+ i->show();
+ }
}
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
*/
void MainWindowImp::getInterfaceList(){
KShellProcess *processAll = new KShellProcess();
*processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
connect(processAll, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(processAll, TEMP_ALL);
processAll->start(KShellProcess::NotifyOnExit);
KShellProcess *process = new KShellProcess();
*process << "/sbin/ifconfig" << " > " TEMP_UP;
connect(process, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(process, TEMP_UP);
process->start(KShellProcess::NotifyOnExit);
}
void MainWindowImp::jobDone(KProcess *process){
QString fileName = threads[process];
threads.remove(process);
delete process;
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
return;
}
QTextStream stream( &file );
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;
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(interfaceName, false);
else
i = new Interface(interfaceName, true);
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
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);
}
}
file.close();
QFile::remove(fileName);
}
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// See if we already have it
if(items.find(i) == items.end()){
item = new QListViewItem(serviceList, "", "", "");
// See if you can't find a module owner for this interface
- //EmployeeMap::Iterator it;
- //for( it = map.begin(); it != map.end(); ++it )
- // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
-
+ QMap<Module*, QLibrary*>::Iterator it;
+ for( it = libraries.begin(); it != libraries.end(); ++it ){
+ if(it.key()->isOwner(i))
+ i->setModuleOwner(it.key());
+ }
+
items.insert(i, item);
interfaceItems.insert(item, i);
}
else
item = items[i];
QString statusImage = "down";
if(i->getStatus())
statusImage = "up";
QPixmap status = (Resource::loadPixmap(statusImage));
item->setPixmap(0, status);
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";
+ // Actually try to use the Module
+ if(i->getModuleOwner() != NULL){
+ typeName = i->getModuleOwner()->getPixmapName(i);
+ }
QPixmap type = (Resource::loadPixmap(typeName));
item->setPixmap(1, type);
item->setText(2, i->getHardwareName());
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the combo and QStringList
*/
void MainWindowImp::addProfile(){
QString newProfileName = "New";
if(profiles.grep(newProfileName).count() > 0){
QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok");
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile(){
if(profilesList->count() <= 1){
QMessageBox::information(this, "Can't remove anything.","Need One Profile.", "Ok");
return;
}
QString profileToRemove = profilesList->currentText();
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
}
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile(const QString& newProfile){
currentProfileLabel->setText(newProfile);
}
// mainwindowimp.cpp
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 8e300bf..19ebaf2 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,57 +1,56 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
#include <qmap.h>
#include <qstringlist.h>
class Module;
class Interface;
class QLibrary;
class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void jobDone(KProcess *process);
void getInterfaceList();
void addProfile();
void removeProfile();
void changeProfile(const QString&);
void updateInterface(Interface *i);
private:
void loadModules(QString path);
Module* loadPlugin(QString pluginFileName,
QString resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
- QMap<Interface*, Module*> modules;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
QStringList profiles;
};
#endif
// mainwindowimp.h
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index 13fd523..c1e9488 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -1,33 +1,34 @@
#ifndef NETCONF_MODULE_H
#define NETCONF_MODULE_H
#include <qobject.h>
#include <qlist.h>
#include <qmap.h>
#include "interface.h"
class QWidget;
+class QTabWidget;
class Module : QObject{
signals:
void updateInterface(Interface *i);
public:
Module(){};
virtual bool isOwner(Interface *){ return false; };
- virtual QWidget *configure(){ return NULL; } ;
- virtual QWidget *information(){ return NULL; };
+ virtual QWidget *configure(QTabWidget **tabWidget){ return NULL; } ;
+ virtual QWidget *information(QTabWidget **tabWidget){ return NULL; };
virtual QList<Interface> getInterfaces() = 0;
virtual QMap<QString, QString> possibleNewInterfaces() = 0;
virtual Interface *addNewInterface(QString name) = 0;
virtual bool remove(Interface* i) = 0;
-
+ virtual QString getPixmapName(Interface* i) = 0;
};
#endif
// module.h
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro
index a01b050..0d48790 100644
--- a/noncore/settings/networksettings/networksetup.pro
+++ b/noncore/settings/networksettings/networksetup.pro
@@ -1,10 +1,10 @@
TEMPLATE = app
-CONFIG = qt warn_on debug
-#CONFIG = qt warn_on release
+#CONFIG = qt warn_on debug
+CONFIG = qt warn_on release
HEADERS = mainwindowimp.h addserviceimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h
SOURCES = main.cpp mainwindowimp.cpp addserviceimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
#INCLUDEPATH += $(QPEDIR)/include
#DEPENDPATH += $(QPEDIR)/include
LIBS += -lqpe
INTERFACES = mainwindow.ui addservice.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
TARGET = networksetup