summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-09-30 14:46:34 (UTC)
committer benmeyer <benmeyer>2002-09-30 14:46:34 (UTC)
commitd79ae2969e74b1caa8e562910715df4ffe1739b3 (patch) (unidiff)
tree1808d0d3747581ca999ec42b4bb029471a1aa199
parent9965bd5c49ff2f22d640d132ac343fdec97b3fb4 (diff)
downloadopie-d79ae2969e74b1caa8e562910715df4ffe1739b3.zip
opie-d79ae2969e74b1caa8e562910715df4ffe1739b3.tar.gz
opie-d79ae2969e74b1caa8e562910715df4ffe1739b3.tar.bz2
Fixed compiler warnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interface.cpp2
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h2
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp15
-rw-r--r--noncore/net/networksetup/mainwindowimp.h9
-rw-r--r--noncore/settings/networksettings/interface.cpp2
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h2
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp15
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h9
8 files changed, 42 insertions, 14 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index b9b09ad..f6eed00 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -70,167 +70,167 @@ bool Interface::refresh(){
70 subnetMask = "0.0.0.0"; 70 subnetMask = "0.0.0.0";
71 broadcast = ""; 71 broadcast = "";
72 dhcp = false; 72 dhcp = false;
73 dhcpServerIp = ""; 73 dhcpServerIp = "";
74 leaseObtained = ""; 74 leaseObtained = "";
75 leaseExpires = ""; 75 leaseExpires = "";
76 return true; 76 return true;
77 } 77 }
78 78
79 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); 79 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName);
80 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); 80 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
81 if(ret != 0){ 81 if(ret != 0){
82 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 82 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
83 return false; 83 return false;
84 } 84 }
85 85
86 QFile file(fileName); 86 QFile file(fileName);
87 if (!file.open(IO_ReadOnly)){ 87 if (!file.open(IO_ReadOnly)){
88 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 88 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
89 return false; 89 return false;
90 } 90 }
91 91
92 // Set to the defaults 92 // Set to the defaults
93 macAddress = ""; 93 macAddress = "";
94 ip = "0.0.0.0"; 94 ip = "0.0.0.0";
95 subnetMask = "0.0.0.0"; 95 subnetMask = "0.0.0.0";
96 broadcast = ""; 96 broadcast = "";
97 97
98 QTextStream stream( &file ); 98 QTextStream stream( &file );
99 QString line; 99 QString line;
100 while ( !stream.eof() ) { 100 while ( !stream.eof() ) {
101 line = stream.readLine(); 101 line = stream.readLine();
102 if(line.contains("HWaddr")){ 102 if(line.contains("HWaddr")){
103 int mac = line.find("HWaddr"); 103 int mac = line.find("HWaddr");
104 macAddress = line.mid(mac+7, line.length()); 104 macAddress = line.mid(mac+7, line.length());
105 } 105 }
106 if(line.contains("inet addr")){ 106 if(line.contains("inet addr")){
107 int ipl = line.find("inet addr"); 107 int ipl = line.find("inet addr");
108 int space = line.find(" ", ipl+10); 108 int space = line.find(" ", ipl+10);
109 ip = line.mid(ipl+10, space-ipl-10); 109 ip = line.mid(ipl+10, space-ipl-10);
110 } 110 }
111 if(line.contains("Mask")){ 111 if(line.contains("Mask")){
112 int mask = line.find("Mask"); 112 int mask = line.find("Mask");
113 subnetMask = line.mid(mask+5, line.length()); 113 subnetMask = line.mid(mask+5, line.length());
114 } 114 }
115 if(line.contains("Bcast")){ 115 if(line.contains("Bcast")){
116 int mask = line.find("Bcast"); 116 int mask = line.find("Bcast");
117 int space = line.find(" ", mask+6); 117 int space = line.find(" ", mask+6);
118 broadcast = line.mid(mask+6, space-mask-6); 118 broadcast = line.mid(mask+6, space-mask-6);
119 } 119 }
120 } 120 }
121 file.close(); 121 file.close();
122 QFile::remove(fileName); 122 QFile::remove(fileName);
123 123
124 // DHCP TESTING 124 // DHCP TESTING
125 // reset DHCP info 125 // reset DHCP info
126 dhcpServerIp = ""; 126 dhcpServerIp = "";
127 leaseObtained = ""; 127 leaseObtained = "";
128 leaseExpires = ""; 128 leaseExpires = "";
129 dhcp = false; 129 dhcp = false;
130 130
131 // See if we have 131 // See if we have
132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); 132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName));
133 // If there is no DHCP information then exit now with no errors. 133 // If there is no DHCP information then exit now with no errors.
134 if(!QFile::exists(dhcpFile)){ 134 if(!QFile::exists(dhcpFile)){
135 return true; 135 return true;
136 } 136 }
137 137
138 file.setName(dhcpFile); 138 file.setName(dhcpFile);
139 if (!file.open(IO_ReadOnly)){ 139 if (!file.open(IO_ReadOnly)){
140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
141 return false; 141 return false;
142 } 142 }
143 143
144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
145 int leaseTime = 0; 145 int leaseTime = 0;
146 int renewalTime = 0; 146 int renewalTime = 0;
147 147
148 stream.setDevice( &file ); 148 stream.setDevice( &file );
149 while ( !stream.eof() ) { 149 while ( !stream.eof() ) {
150 line = stream.readLine(); 150 line = stream.readLine();
151 if(line.contains("DHCPSID=")) 151 if(line.contains("DHCPSID="))
152 dhcpServerIp = line.mid(8, line.length()); 152 dhcpServerIp = line.mid(8, line.length());
153 if(line.contains("LEASETIME=")) 153 if(line.contains("LEASETIME="))
154 leaseTime = line.mid(10, line.length()).toInt(); 154 leaseTime = line.mid(10, line.length()).toInt();
155 if(line.contains("RENEWALTIME=")) 155 if(line.contains("RENEWALTIME="))
156 renewalTime = line.mid(12, line.length()).toInt(); 156 renewalTime = line.mid(12, line.length()).toInt();
157 } 157 }
158 file.close(); 158 file.close();
159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
161 161
162 // Get the pid of the deamond 162 // Get the pid of the deamond
163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); 163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName));
164 file.setName(dhcpFile); 164 file.setName(dhcpFile);
165 if (!file.open(IO_ReadOnly)){ 165 if (!file.open(IO_ReadOnly)){
166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
167 return false; 167 return false;
168 } 168 }
169 169
170 int pid = -1; 170 int pid = -1;
171 stream.setDevice( &file ); 171 stream.setDevice( &file );
172 while ( !stream.eof() ) { 172 while ( !stream.eof() ) {
173 line = stream.readLine(); 173 line = stream.readLine();
174 pid = line.toInt(); 174 pid = line.toInt();
175 } 175 }
176 file.close(); 176 file.close();
177 177
178 if( pid == -1){ 178 if( pid == -1){
179 qDebug("Interface: Could not get pid of dhcpc deamon."); 179 qDebug("Interface: Could not get pid of dhcpc deamon.");
180 return false; 180 return false;
181 } 181 }
182 182
183 // Get the start running time of the deamon 183 // Get the start running time of the deamon
184 fileName = (QString("/proc/%1/stat").arg(pid)); 184 fileName = (QString("/proc/%1/stat").arg(pid));
185 file.setName(fileName); 185 file.setName(fileName);
186 stream.setDevice( &file ); 186 stream.setDevice( &file );
187 if (!file.open(IO_ReadOnly)){ 187 if (!file.open(IO_ReadOnly)){
188 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 188 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
189 return false; 189 return false;
190 } 190 }
191 while ( !stream.eof() ) { 191 while ( !stream.eof() ) {
192 line = stream.readLine(); 192 line = stream.readLine();
193 } 193 }
194 file.close(); 194 file.close();
195 long time = 0; 195 long time = 0;
196 // Grab the start time 196 // Grab the start time
197 // pid com state ppid pgrp session tty_nr tpgid flags 197 // pid com state ppid pgrp session tty_nr tpgid flags
198 int r = sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 198 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
199 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 199 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
200 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 200 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
201 // nice 0 itrealvalue starttime 201 // nice 0 itrealvalue starttime
202 "%*d %*d %*d %lu", (long*) &time); 202 "%*d %*d %*d %lu", (long*) &time);
203 time = time/100; 203 time = time/100;
204 204
205 QDateTime datetime(QDateTime::currentDateTime()); 205 QDateTime datetime(QDateTime::currentDateTime());
206 206
207 // Get the uptime of the computer. 207 // Get the uptime of the computer.
208 QFile f("/proc/uptime"); 208 QFile f("/proc/uptime");
209 if ( f.open(IO_ReadOnly) ) { // file opened successfully 209 if ( f.open(IO_ReadOnly) ) { // file opened successfully
210 QTextStream t( &f ); // use a text stream 210 QTextStream t( &f ); // use a text stream
211 int sec = 0; 211 int sec = 0;
212 t >> sec; 212 t >> sec;
213 datetime = datetime.addSecs((-1*sec)); 213 datetime = datetime.addSecs((-1*sec));
214 f.close(); 214 f.close();
215 } 215 }
216 else{ 216 else{
217 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 217 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
218 return false; 218 return false;
219 } 219 }
220 220
221 datetime = datetime.addSecs(time); 221 datetime = datetime.addSecs(time);
222 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 222 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
223 223
224 // Calculate the start and renew times 224 // Calculate the start and renew times
225 leaseObtained= datetime.toString(); 225 leaseObtained= datetime.toString();
226 226
227 // Calculate the start and renew times 227 // Calculate the start and renew times
228 datetime = datetime.addSecs(leaseTime); 228 datetime = datetime.addSecs(leaseTime);
229 leaseExpires = datetime.toString(); 229 leaseExpires = datetime.toString();
230 230
231 dhcp = true; 231 dhcp = true;
232 return true; 232 return true;
233} 233}
234 234
235// interface.cpp 235// interface.cpp
236 236
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
index 6fc2384..c8a478e 100644
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaceinformationimp.h
@@ -1,31 +1,31 @@
1#ifndef INTERFACEINFORMATIONIMP_H 1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H 2#define INTERFACEINFORMATIONIMP_H
3 3
4#include "interfaceinformation.h" 4#include "interfaceinformation.h"
5#include "interface.h" 5#include "interface.h"
6 6
7class InterfaceInformationImp : public InterfaceInformation { 7class InterfaceInformationImp : public InterfaceInformation {
8 8
9Q_OBJECT 9Q_OBJECT
10 10
11public: 11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); 12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start(); 16 void start();
17 void stop(); 17 void stop();
18 void refresh(); 18 void refresh();
19 void restart(); 19 void restart();
20 void advanced(); 20 void advanced();
21 Interface *interface;
22 21
23private: 22private:
23 Interface *interface;
24 void updateInterface(); 24 void updateInterface();
25 25
26}; 26};
27 27
28#endif 28#endif
29 29
30// addserviceimp.h 30// addserviceimp.h
31 31
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 3c13143..ad9362f 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,308 +1,319 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addserviceimp.h" 2#include "addserviceimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h"
6#include "kprocess.h"
7#include "module.h"
5 8
6#include <qpushbutton.h> 9#include <qpushbutton.h>
7#include <qdir.h> 10#include <qdir.h>
8#include <qtabwidget.h> 11#include <qtabwidget.h>
9#include <qmainwindow.h> 12#include <qmainwindow.h>
10#include <qmessagebox.h> 13#include <qmessagebox.h>
11#include <qlistbox.h> 14#include <qlistbox.h>
12#include <qpe/config.h> 15#include <qpe/config.h>
13#include <qpe/qlibrary.h> 16#include <qpe/qlibrary.h>
14#include <qpe/resource.h> 17#include <qpe/resource.h>
15#include <qlist.h> 18#include <qlist.h>
16 19
17#include <qfile.h> 20#include <qfile.h>
18#include <qtextstream.h> 21#include <qtextstream.h>
19#include <qlistview.h> 22#include <qlistview.h>
20#include <qheader.h> 23#include <qheader.h>
21// For library loading. 24// For library loading.
22#include <dlfcn.h> 25#include <dlfcn.h>
23 26
24#define TEMP_ALL "/tmp/ifconfig-a" 27#define TEMP_ALL "/tmp/ifconfig-a"
25#define TEMP_UP "/tmp/ifconfig" 28#define TEMP_UP "/tmp/ifconfig"
26 29
27#define NO_SELECT_ERROR_AND_RETURN { \ 30#define NO_SELECT_ERROR_AND_RETURN { \
28 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \ 31 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
29 return; \ 32 return; \
30} 33}
31 34
32MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
33 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
34 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
35 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
36 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
37 // Make sure we have a plugin directory to scan. 40 // Make sure we have a plugin directory to scan.
38 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
39 QDir pluginDir( DirStr ); 42 QDir pluginDir( DirStr );
40 pluginDir.mkdir( DirStr ); 43 pluginDir.mkdir( DirStr );
41 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 44 pluginDir.mkdir( ( DirStr + "plugins/" ) );
42 QString path = DirStr + "plugins"; 45 QString path = DirStr + "plugins";
43 pluginDir.setPath(path); 46 pluginDir.setPath(path);
44 if(!pluginDir.exists()){ 47 if(!pluginDir.exists()){
45 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1()); 48 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
46 return; 49 return;
47 } 50 }
48 51
49 // Load any saved services. 52 // Load any saved services.
50 loadModules(path); 53 loadModules(path);
51 getInterfaceList(); 54 getInterfaceList();
52 serviceList->header()->hide(); 55 serviceList->header()->hide();
56
57
58 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
53} 60}
54 61
55/** 62/**
56 * Deconstructor. Unload libraries and save. 63 * Deconstructor. Unload libraries and save profile list.
57 */ 64 */
58MainWindowImp::~MainWindowImp(){ 65MainWindowImp::~MainWindowImp(){
66 if(profiles.count() > 1){
67 Config cfg("NetworkSetup");
68 cfg.writeEntry("Profiles", profiles.join(" "));
69 }
59} 70}
60 71
61void MainWindowImp::loadModules(QString path){ 72void MainWindowImp::loadModules(QString path){
62} 73}
63 74
64/** 75/**
65 * Attempt to load a function and resolve a function. 76 * Attempt to load a function and resolve a function.
66 * @param pluginFileName - the name of the file in which to attempt to load 77 * @param pluginFileName - the name of the file in which to attempt to load
67 * @param resolveString - function pointer to resolve 78 * @param resolveString - function pointer to resolve
68 * @return pointer to the function with name resolveString or NULL 79 * @return pointer to the function with name resolveString or NULL
69 */ 80 */
70Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 81Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
71 //qDebug(pluginFileName.latin1()); 82 //qDebug(pluginFileName.latin1());
72 QLibrary *lib = new QLibrary(pluginFileName); 83 QLibrary *lib = new QLibrary(pluginFileName);
73 void *functionPointer = lib->resolve(resolveString); 84 void *functionPointer = lib->resolve(resolveString);
74 if( !functionPointer ){ 85 if( !functionPointer ){
75 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 86 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
76 delete lib; 87 delete lib;
77 return NULL; 88 return NULL;
78 } 89 }
79 90
80 // Try to get an object. 91 // Try to get an object.
81 Module *object = ((Module* (*)()) functionPointer)(); 92 Module *object = ((Module* (*)()) functionPointer)();
82 if(object == NULL){ 93 if(object == NULL){
83 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 94 qDebug("MainWindowImp: Couldn't create object, but did load library!");
84 delete lib; 95 delete lib;
85 return NULL; 96 return NULL;
86 } 97 }
87 98
88 // Store for reference 99 // Store for reference
89 libraries.insert(object, lib); 100 libraries.insert(object, lib);
90 return object; 101 return object;
91} 102}
92 103
93/* 104/*
94QList<QString> MainWindowImp::retrieveUnloadedPluginList(){ 105QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
95 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 106 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
96 QString path = DirStr + "plugins"; 107 QString path = DirStr + "plugins";
97 QDir d(path); 108 QDir d(path);
98 d.setFilter( QDir::Files | QDir::Hidden ); 109 d.setFilter( QDir::Files | QDir::Hidden );
99 110
100 QMap<QObject*, QLibrary*>::Iterator libraryIt; 111 QMap<QObject*, QLibrary*>::Iterator libraryIt;
101 QList<QString> rlist; 112 QList<QString> rlist;
102 rlist.setAutoDelete(false); 113 rlist.setAutoDelete(false);
103 114
104 const QFileInfoList *list = d.entryInfoList(); 115 const QFileInfoList *list = d.entryInfoList();
105 QFileInfoListIterator it( *list ); 116 QFileInfoListIterator it( *list );
106 QFileInfo *fi; 117 QFileInfo *fi;
107 while ( (fi=it.current()) ) { 118 while ( (fi=it.current()) ) {
108 if(fi->fileName().contains(".so")){ 119 if(fi->fileName().contains(".so")){
109 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt ) 120 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
110 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){ 121 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
111 QString *s = new QString(path + "/" + fi->fileName()); 122 QString *s = new QString(path + "/" + fi->fileName());
112 rlist.append(s); 123 rlist.append(s);
113 } 124 }
114 } 125 }
115 ++it; 126 ++it;
116 } 127 }
117 return rlist; 128 return rlist;
118} 129}
119*/ 130*/
120 131
121/** 132/**
122 * The Add button was clicked. Bring up the add dialog and if OK is hit 133 * The Add button was clicked. Bring up the add dialog and if OK is hit
123 * load the plugin and append it to the list 134 * load the plugin and append it to the list
124 */ 135 */
125void MainWindowImp::addClicked(){ 136void MainWindowImp::addClicked(){
126 // Now that we have a list of all of the protocals, list them. 137 // Now that we have a list of all of the protocals, list them.
127 { 138 {
128 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok"); 139 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
129 return; 140 return;
130 } 141 }
131 AddServiceImp service(this, "AddService", true); 142 AddServiceImp service(this, "AddService", true);
132 service.showMaximized(); 143 service.showMaximized();
133 service.exec(); 144 service.exec();
134} 145}
135 146
136/** 147/**
137 * Prompt the user to see if they really want to do this. 148 * Prompt the user to see if they really want to do this.
138 * If they do then remove from the list and unload. 149 * If they do then remove from the list and unload.
139 */ 150 */
140void MainWindowImp::removeClicked(){ 151void MainWindowImp::removeClicked(){
141 QListViewItem *item = serviceList->currentItem(); 152 QListViewItem *item = serviceList->currentItem();
142 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 153 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
143 154
144 if(modules.find(interfaceItems[item]) == modules.end()){ 155 if(modules.find(interfaceItems[item]) == modules.end()){
145 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 156 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
146 } 157 }
147 else{ 158 else{
148 // Try to remove. 159 // Try to remove.
149 } 160 }
150 161
151} 162}
152 163
153/** 164/**
154 * See if there is a configuration for the selected protocal. 165 * See if there is a configuration for the selected protocal.
155 * Prompt with errors. 166 * Prompt with errors.
156 */ 167 */
157void MainWindowImp::configureClicked(){ 168void MainWindowImp::configureClicked(){
158 QListViewItem *item = serviceList->currentItem(); 169 QListViewItem *item = serviceList->currentItem();
159 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 170 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
160 171
161 if(modules.find(interfaceItems[item]) == modules.end()){ 172 if(modules.find(interfaceItems[item]) == modules.end()){
162 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); 173 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
163 conf->showMaximized(); 174 conf->showMaximized();
164 conf->show(); 175 conf->show();
165 } 176 }
166 else{ 177 else{
167 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); 178 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
168 conf->show(); 179 conf->show();
169 } 180 }
170} 181}
171 182
172/** 183/**
173 * Pull up the information about the selected interface 184 * Pull up the information about the selected interface
174 * Report an error 185 * Report an error
175 */ 186 */
176void MainWindowImp::informationClicked(){ 187void MainWindowImp::informationClicked(){
177 QListViewItem *item = serviceList->currentItem(); 188 QListViewItem *item = serviceList->currentItem();
178 if(item == NULL)NO_SELECT_ERROR_AND_RETURN 189 if(item == NULL)NO_SELECT_ERROR_AND_RETURN
179 190
180 if(modules.find(interfaceItems[item]) == modules.end()){ 191 if(modules.find(interfaceItems[item]) == modules.end()){
181 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); 192 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
182 i->showMaximized(); 193 i->showMaximized();
183 i->show(); 194 i->show();
184 } 195 }
185 else{ 196 else{
186 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); 197 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
187 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); 198 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
188 t->insertTab(i, "TCP/IP"); 199 t->insertTab(i, "TCP/IP");
189 t->show(); 200 t->show();
190 } 201 }
191} 202}
192 203
193/** 204/**
194 * Aquire the list of active interfaces from ifconfig 205 * Aquire the list of active interfaces from ifconfig
195 * Call ifconfig and ifconfig -a 206 * Call ifconfig and ifconfig -a
196 */ 207 */
197void MainWindowImp::getInterfaceList(){ 208void MainWindowImp::getInterfaceList(){
198 KShellProcess *processAll = new KShellProcess(); 209 KShellProcess *processAll = new KShellProcess();
199 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 210 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
200 connect(processAll, SIGNAL(processExited(KProcess *)), 211 connect(processAll, SIGNAL(processExited(KProcess *)),
201 this, SLOT(jobDone(KProcess *))); 212 this, SLOT(jobDone(KProcess *)));
202 threads.insert(processAll, TEMP_ALL); 213 threads.insert(processAll, TEMP_ALL);
203 processAll->start(KShellProcess::NotifyOnExit); 214 processAll->start(KShellProcess::NotifyOnExit);
204 215
205 KShellProcess *process = new KShellProcess(); 216 KShellProcess *process = new KShellProcess();
206 *process << "/sbin/ifconfig" << " > " TEMP_UP; 217 *process << "/sbin/ifconfig" << " > " TEMP_UP;
207 connect(process, SIGNAL(processExited(KProcess *)), 218 connect(process, SIGNAL(processExited(KProcess *)),
208 this, SLOT(jobDone(KProcess *))); 219 this, SLOT(jobDone(KProcess *)));
209 threads.insert(process, TEMP_UP); 220 threads.insert(process, TEMP_UP);
210 process->start(KShellProcess::NotifyOnExit); 221 process->start(KShellProcess::NotifyOnExit);
211} 222}
212 223
213void MainWindowImp::jobDone(KProcess *process){ 224void MainWindowImp::jobDone(KProcess *process){
214 QString fileName = threads[process]; 225 QString fileName = threads[process];
215 threads.remove(process); 226 threads.remove(process);
216 delete process; 227 delete process;
217 228
218 QFile file(fileName); 229 QFile file(fileName);
219 if (!file.open(IO_ReadOnly)){ 230 if (!file.open(IO_ReadOnly)){
220 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 231 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
221 return; 232 return;
222 } 233 }
223 234
224 QTextStream stream( &file ); 235 QTextStream stream( &file );
225 QString line; 236 QString line;
226 while ( !stream.eof() ) { 237 while ( !stream.eof() ) {
227 line = stream.readLine(); 238 line = stream.readLine();
228 int space = line.find(" "); 239 int space = line.find(" ");
229 if(space > 1){ 240 if(space > 1){
230 // We have found an interface 241 // We have found an interface
231 QString interfaceName = line.mid(0, space); 242 QString interfaceName = line.mid(0, space);
232 Interface *i; 243 Interface *i;
233 // See if we already have it 244 // See if we already have it
234 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 245 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
235 if(fileName == TEMP_ALL) 246 if(fileName == TEMP_ALL)
236 i = new Interface(interfaceName, false); 247 i = new Interface(interfaceName, false);
237 else 248 else
238 i = new Interface(interfaceName, true); 249 i = new Interface(interfaceName, true);
239 } 250 }
240 else{ 251 else{
241 i = interfaceNames[interfaceName]; 252 i = interfaceNames[interfaceName];
242 if(fileName != TEMP_ALL) 253 if(fileName != TEMP_ALL)
243 i->setStatus(true); 254 i->setStatus(true);
244 } 255 }
245 256
246 i->setAttached(true); 257 i->setAttached(true);
247 i->setInterfaceName(interfaceName); 258 i->setInterfaceName(interfaceName);
248 259
249 QString hardName = "Ethernet"; 260 QString hardName = "Ethernet";
250 int hardwareName = line.find("Link encap:"); 261 int hardwareName = line.find("Link encap:");
251 int macAddress = line.find("HWaddr"); 262 int macAddress = line.find("HWaddr");
252 if(macAddress == -1) 263 if(macAddress == -1)
253 macAddress = line.length(); 264 macAddress = line.length();
254 if(hardwareName != -1) 265 if(hardwareName != -1)
255 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11))); 266 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
256 // We have found an interface 267 // We have found an interface
257 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 268 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
258 interfaceNames.insert(i->getInterfaceName(), i); 269 interfaceNames.insert(i->getInterfaceName(), i);
259 updateInterface(i); 270 updateInterface(i);
260 } 271 }
261 } 272 }
262 file.close(); 273 file.close();
263 QFile::remove(fileName); 274 QFile::remove(fileName);
264} 275}
265 276
266void MainWindowImp::updateInterface(Interface *i){ 277void MainWindowImp::updateInterface(Interface *i){
267 QListViewItem *item = NULL; 278 QListViewItem *item = NULL;
268 279
269 // See if we already have it 280 // See if we already have it
270 if(items.find(i) == items.end()){ 281 if(items.find(i) == items.end()){
271 item = new QListViewItem(serviceList, "", "", ""); 282 item = new QListViewItem(serviceList, "", "", "");
272 // See if you can't find a module owner for this interface 283 // See if you can't find a module owner for this interface
273 //EmployeeMap::Iterator it; 284 //EmployeeMap::Iterator it;
274 //for( it = map.begin(); it != map.end(); ++it ) 285 //for( it = map.begin(); it != map.end(); ++it )
275 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); 286 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
276 287
277 items.insert(i, item); 288 items.insert(i, item);
278 interfaceItems.insert(item, i); 289 interfaceItems.insert(item, i);
279 } 290 }
280 else 291 else
281 item = items[i]; 292 item = items[i];
282 293
283 QString statusImage = "down"; 294 QString statusImage = "down";
284 if(i->getStatus()) 295 if(i->getStatus())
285 statusImage = "up"; 296 statusImage = "up";
286 QPixmap status = (Resource::loadPixmap(statusImage)); 297 QPixmap status = (Resource::loadPixmap(statusImage));
287 item->setPixmap(0, status); 298 item->setPixmap(0, status);
288 299
289 QString typeName = "lan"; 300 QString typeName = "lan";
290 if(i->getHardwareName().contains("Local Loopback")) 301 if(i->getHardwareName().contains("Local Loopback"))
291 typeName = "lo"; 302 typeName = "lo";
292 QPixmap type = (Resource::loadPixmap(typeName)); 303 QPixmap type = (Resource::loadPixmap(typeName));
293 item->setPixmap(1, type); 304 item->setPixmap(1, type);
294 305
295 item->setText(2, i->getHardwareName()); 306 item->setText(2, i->getHardwareName());
296 307
297} 308}
298 309
299void MainWindowImp::addProfile(){ 310void MainWindowImp::addProfile(){
300 311
301} 312}
302 313
303void MainWindowImp::removeProfile(){ 314void MainWindowImp::removeProfile(){
304 315
305} 316}
306 317
307// mainwindowimp.cpp 318// mainwindowimp.cpp
308 319
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 95ec2a1..0618dd2 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -1,53 +1,56 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "module.h"
6#include "interface.h"
7#include "kprocess.h"
8#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h>
9 7
8class Module;
9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess;
11 12
12class MainWindowImp : public MainWindow { 13class MainWindowImp : public MainWindow {
13 Q_OBJECT 14 Q_OBJECT
14 15
15public: 16public:
16 MainWindowImp(QWidget *parent=0, const char *name=0); 17 MainWindowImp(QWidget *parent=0, const char *name=0);
17 ~MainWindowImp(); 18 ~MainWindowImp();
18 19
19private slots: 20private slots:
20 void addClicked(); 21 void addClicked();
21 void removeClicked(); 22 void removeClicked();
22 void configureClicked(); 23 void configureClicked();
23 void informationClicked(); 24 void informationClicked();
24 25
25 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
26 void getInterfaceList(); 27 void getInterfaceList();
27 28
28 void addProfile(); 29 void addProfile();
29 void removeProfile(); 30 void removeProfile();
30 31
31 void updateInterface(Interface *i); 32 void updateInterface(Interface *i);
32 33
33private: 34private:
34 void loadModules(QString path); 35 void loadModules(QString path);
35 36
36 Module* loadPlugin(QString pluginFileName, 37 Module* loadPlugin(QString pluginFileName,
37 QString resolveString = "create_plugin"); 38 QString resolveString = "create_plugin");
38 39
39 // For our local list of names 40 // For our local list of names
40 QMap<QString, Interface*> interfaceNames; 41 QMap<QString, Interface*> interfaceNames;
41 42
42 QMap<Module*, QLibrary*> libraries; 43 QMap<Module*, QLibrary*> libraries;
43 QMap<Interface*, Module*> modules; 44 QMap<Interface*, Module*> modules;
44 QMap<Interface*, QListViewItem*> items; 45 QMap<Interface*, QListViewItem*> items;
45 QMap<QListViewItem*, Interface*> interfaceItems; 46 QMap<QListViewItem*, Interface*> interfaceItems;
46 47
47 QMap<KProcess*, QString> threads; 48 QMap<KProcess*, QString> threads;
49 QStringList profiles;
50
48}; 51};
49 52
50#endif 53#endif
51 54
52// mainwindowimp.h 55// mainwindowimp.h
53 56
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index b9b09ad..f6eed00 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -70,167 +70,167 @@ bool Interface::refresh(){
70 subnetMask = "0.0.0.0"; 70 subnetMask = "0.0.0.0";
71 broadcast = ""; 71 broadcast = "";
72 dhcp = false; 72 dhcp = false;
73 dhcpServerIp = ""; 73 dhcpServerIp = "";
74 leaseObtained = ""; 74 leaseObtained = "";
75 leaseExpires = ""; 75 leaseExpires = "";
76 return true; 76 return true;
77 } 77 }
78 78
79 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName); 79 QString fileName = QString("/tmp/%1_ifconfig_info").arg(interfaceName);
80 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1()); 80 int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(interfaceName).arg(fileName).latin1());
81 if(ret != 0){ 81 if(ret != 0){
82 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); 82 qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1());
83 return false; 83 return false;
84 } 84 }
85 85
86 QFile file(fileName); 86 QFile file(fileName);
87 if (!file.open(IO_ReadOnly)){ 87 if (!file.open(IO_ReadOnly)){
88 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 88 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
89 return false; 89 return false;
90 } 90 }
91 91
92 // Set to the defaults 92 // Set to the defaults
93 macAddress = ""; 93 macAddress = "";
94 ip = "0.0.0.0"; 94 ip = "0.0.0.0";
95 subnetMask = "0.0.0.0"; 95 subnetMask = "0.0.0.0";
96 broadcast = ""; 96 broadcast = "";
97 97
98 QTextStream stream( &file ); 98 QTextStream stream( &file );
99 QString line; 99 QString line;
100 while ( !stream.eof() ) { 100 while ( !stream.eof() ) {
101 line = stream.readLine(); 101 line = stream.readLine();
102 if(line.contains("HWaddr")){ 102 if(line.contains("HWaddr")){
103 int mac = line.find("HWaddr"); 103 int mac = line.find("HWaddr");
104 macAddress = line.mid(mac+7, line.length()); 104 macAddress = line.mid(mac+7, line.length());
105 } 105 }
106 if(line.contains("inet addr")){ 106 if(line.contains("inet addr")){
107 int ipl = line.find("inet addr"); 107 int ipl = line.find("inet addr");
108 int space = line.find(" ", ipl+10); 108 int space = line.find(" ", ipl+10);
109 ip = line.mid(ipl+10, space-ipl-10); 109 ip = line.mid(ipl+10, space-ipl-10);
110 } 110 }
111 if(line.contains("Mask")){ 111 if(line.contains("Mask")){
112 int mask = line.find("Mask"); 112 int mask = line.find("Mask");
113 subnetMask = line.mid(mask+5, line.length()); 113 subnetMask = line.mid(mask+5, line.length());
114 } 114 }
115 if(line.contains("Bcast")){ 115 if(line.contains("Bcast")){
116 int mask = line.find("Bcast"); 116 int mask = line.find("Bcast");
117 int space = line.find(" ", mask+6); 117 int space = line.find(" ", mask+6);
118 broadcast = line.mid(mask+6, space-mask-6); 118 broadcast = line.mid(mask+6, space-mask-6);
119 } 119 }
120 } 120 }
121 file.close(); 121 file.close();
122 QFile::remove(fileName); 122 QFile::remove(fileName);
123 123
124 // DHCP TESTING 124 // DHCP TESTING
125 // reset DHCP info 125 // reset DHCP info
126 dhcpServerIp = ""; 126 dhcpServerIp = "";
127 leaseObtained = ""; 127 leaseObtained = "";
128 leaseExpires = ""; 128 leaseExpires = "";
129 dhcp = false; 129 dhcp = false;
130 130
131 // See if we have 131 // See if we have
132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); 132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName));
133 // If there is no DHCP information then exit now with no errors. 133 // If there is no DHCP information then exit now with no errors.
134 if(!QFile::exists(dhcpFile)){ 134 if(!QFile::exists(dhcpFile)){
135 return true; 135 return true;
136 } 136 }
137 137
138 file.setName(dhcpFile); 138 file.setName(dhcpFile);
139 if (!file.open(IO_ReadOnly)){ 139 if (!file.open(IO_ReadOnly)){
140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
141 return false; 141 return false;
142 } 142 }
143 143
144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
145 int leaseTime = 0; 145 int leaseTime = 0;
146 int renewalTime = 0; 146 int renewalTime = 0;
147 147
148 stream.setDevice( &file ); 148 stream.setDevice( &file );
149 while ( !stream.eof() ) { 149 while ( !stream.eof() ) {
150 line = stream.readLine(); 150 line = stream.readLine();
151 if(line.contains("DHCPSID=")) 151 if(line.contains("DHCPSID="))
152 dhcpServerIp = line.mid(8, line.length()); 152 dhcpServerIp = line.mid(8, line.length());
153 if(line.contains("LEASETIME=")) 153 if(line.contains("LEASETIME="))
154 leaseTime = line.mid(10, line.length()).toInt(); 154 leaseTime = line.mid(10, line.length()).toInt();
155 if(line.contains("RENEWALTIME=")) 155 if(line.contains("RENEWALTIME="))
156 renewalTime = line.mid(12, line.length()).toInt(); 156 renewalTime = line.mid(12, line.length()).toInt();
157 } 157 }
158 file.close(); 158 file.close();
159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
161 161
162 // Get the pid of the deamond 162 // Get the pid of the deamond
163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); 163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName));
164 file.setName(dhcpFile); 164 file.setName(dhcpFile);
165 if (!file.open(IO_ReadOnly)){ 165 if (!file.open(IO_ReadOnly)){
166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
167 return false; 167 return false;
168 } 168 }
169 169
170 int pid = -1; 170 int pid = -1;
171 stream.setDevice( &file ); 171 stream.setDevice( &file );
172 while ( !stream.eof() ) { 172 while ( !stream.eof() ) {
173 line = stream.readLine(); 173 line = stream.readLine();
174 pid = line.toInt(); 174 pid = line.toInt();
175 } 175 }
176 file.close(); 176 file.close();
177 177
178 if( pid == -1){ 178 if( pid == -1){
179 qDebug("Interface: Could not get pid of dhcpc deamon."); 179 qDebug("Interface: Could not get pid of dhcpc deamon.");
180 return false; 180 return false;
181 } 181 }
182 182
183 // Get the start running time of the deamon 183 // Get the start running time of the deamon
184 fileName = (QString("/proc/%1/stat").arg(pid)); 184 fileName = (QString("/proc/%1/stat").arg(pid));
185 file.setName(fileName); 185 file.setName(fileName);
186 stream.setDevice( &file ); 186 stream.setDevice( &file );
187 if (!file.open(IO_ReadOnly)){ 187 if (!file.open(IO_ReadOnly)){
188 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); 188 qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
189 return false; 189 return false;
190 } 190 }
191 while ( !stream.eof() ) { 191 while ( !stream.eof() ) {
192 line = stream.readLine(); 192 line = stream.readLine();
193 } 193 }
194 file.close(); 194 file.close();
195 long time = 0; 195 long time = 0;
196 // Grab the start time 196 // Grab the start time
197 // pid com state ppid pgrp session tty_nr tpgid flags 197 // pid com state ppid pgrp session tty_nr tpgid flags
198 int r = sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " 198 sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
199 // minflt cminflt majflt cmajflt utime stime cutime cstime priority 199 // minflt cminflt majflt cmajflt utime stime cutime cstime priority
200 "%*u %*u %*u %*u %*u %*u %*d %*d %*d " 200 "%*u %*u %*u %*u %*u %*u %*d %*d %*d "
201 // nice 0 itrealvalue starttime 201 // nice 0 itrealvalue starttime
202 "%*d %*d %*d %lu", (long*) &time); 202 "%*d %*d %*d %lu", (long*) &time);
203 time = time/100; 203 time = time/100;
204 204
205 QDateTime datetime(QDateTime::currentDateTime()); 205 QDateTime datetime(QDateTime::currentDateTime());
206 206
207 // Get the uptime of the computer. 207 // Get the uptime of the computer.
208 QFile f("/proc/uptime"); 208 QFile f("/proc/uptime");
209 if ( f.open(IO_ReadOnly) ) { // file opened successfully 209 if ( f.open(IO_ReadOnly) ) { // file opened successfully
210 QTextStream t( &f ); // use a text stream 210 QTextStream t( &f ); // use a text stream
211 int sec = 0; 211 int sec = 0;
212 t >> sec; 212 t >> sec;
213 datetime = datetime.addSecs((-1*sec)); 213 datetime = datetime.addSecs((-1*sec));
214 f.close(); 214 f.close();
215 } 215 }
216 else{ 216 else{
217 qDebug("Interface: Can't open /proc/uptime to retrive uptime."); 217 qDebug("Interface: Can't open /proc/uptime to retrive uptime.");
218 return false; 218 return false;
219 } 219 }
220 220
221 datetime = datetime.addSecs(time); 221 datetime = datetime.addSecs(time);
222 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); 222 //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1());
223 223
224 // Calculate the start and renew times 224 // Calculate the start and renew times
225 leaseObtained= datetime.toString(); 225 leaseObtained= datetime.toString();
226 226
227 // Calculate the start and renew times 227 // Calculate the start and renew times
228 datetime = datetime.addSecs(leaseTime); 228 datetime = datetime.addSecs(leaseTime);
229 leaseExpires = datetime.toString(); 229 leaseExpires = datetime.toString();
230 230
231 dhcp = true; 231 dhcp = true;
232 return true; 232 return true;
233} 233}
234 234
235// interface.cpp 235// interface.cpp
236 236
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
index 6fc2384..c8a478e 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaceinformationimp.h
@@ -1,31 +1,31 @@
1#ifndef INTERFACEINFORMATIONIMP_H 1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H 2#define INTERFACEINFORMATIONIMP_H
3 3
4#include "interfaceinformation.h" 4#include "interfaceinformation.h"
5#include "interface.h" 5#include "interface.h"
6 6
7class InterfaceInformationImp : public InterfaceInformation { 7class InterfaceInformationImp : public InterfaceInformation {
8 8
9Q_OBJECT 9Q_OBJECT
10 10
11public: 11public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); 12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(){}; 13 ~InterfaceInformationImp(){};
14 14
15private slots: 15private slots:
16 void start(); 16 void start();
17 void stop(); 17 void stop();
18 void refresh(); 18 void refresh();
19 void restart(); 19 void restart();
20 void advanced(); 20 void advanced();
21 Interface *interface;
22 21
23private: 22private:
23 Interface *interface;
24 void updateInterface(); 24 void updateInterface();
25 25
26}; 26};
27 27
28#endif 28#endif
29 29
30// addserviceimp.h 30// addserviceimp.h
31 31
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 3c13143..ad9362f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,308 +1,319 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addserviceimp.h" 2#include "addserviceimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interface.h"
6#include "kprocess.h"
7#include "module.h"
5 8
6#include <qpushbutton.h> 9#include <qpushbutton.h>
7#include <qdir.h> 10#include <qdir.h>
8#include <qtabwidget.h> 11#include <qtabwidget.h>
9#include <qmainwindow.h> 12#include <qmainwindow.h>
10#include <qmessagebox.h> 13#include <qmessagebox.h>
11#include <qlistbox.h> 14#include <qlistbox.h>
12#include <qpe/config.h> 15#include <qpe/config.h>
13#include <qpe/qlibrary.h> 16#include <qpe/qlibrary.h>
14#include <qpe/resource.h> 17#include <qpe/resource.h>
15#include <qlist.h> 18#include <qlist.h>
16 19
17#include <qfile.h> 20#include <qfile.h>
18#include <qtextstream.h> 21#include <qtextstream.h>
19#include <qlistview.h> 22#include <qlistview.h>
20#include <qheader.h> 23#include <qheader.h>
21// For library loading. 24// For library loading.
22#include <dlfcn.h> 25#include <dlfcn.h>
23 26
24#define TEMP_ALL "/tmp/ifconfig-a" 27#define TEMP_ALL "/tmp/ifconfig-a"
25#define TEMP_UP "/tmp/ifconfig" 28#define TEMP_UP "/tmp/ifconfig"
26 29
27#define NO_SELECT_ERROR_AND_RETURN { \ 30#define NO_SELECT_ERROR_AND_RETURN { \
28 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \ 31 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); \
29 return; \ 32 return; \
30} 33}
31 34
32MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) { 35MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true) {
33 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked())); 36 connect(addServiceButton, SIGNAL(clicked()), this, SLOT(addClicked()));
34 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 37 connect(removeServiceButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
35 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 38 connect(informationServiceButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
36 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 39 connect(configureServiceButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
37 // Make sure we have a plugin directory to scan. 40 // Make sure we have a plugin directory to scan.
38 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 41 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
39 QDir pluginDir( DirStr ); 42 QDir pluginDir( DirStr );
40 pluginDir.mkdir( DirStr ); 43 pluginDir.mkdir( DirStr );
41 pluginDir.mkdir( ( DirStr + "plugins/" ) ); 44 pluginDir.mkdir( ( DirStr + "plugins/" ) );
42 QString path = DirStr + "plugins"; 45 QString path = DirStr + "plugins";
43 pluginDir.setPath(path); 46 pluginDir.setPath(path);
44 if(!pluginDir.exists()){ 47 if(!pluginDir.exists()){
45 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1()); 48 qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
46 return; 49 return;
47 } 50 }
48 51
49 // Load any saved services. 52 // Load any saved services.
50 loadModules(path); 53 loadModules(path);
51 getInterfaceList(); 54 getInterfaceList();
52 serviceList->header()->hide(); 55 serviceList->header()->hide();
56
57
58 Config cfg("NetworkSetup");
59 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
53} 60}
54 61
55/** 62/**
56 * Deconstructor. Unload libraries and save. 63 * Deconstructor. Unload libraries and save profile list.
57 */ 64 */
58MainWindowImp::~MainWindowImp(){ 65MainWindowImp::~MainWindowImp(){
66 if(profiles.count() > 1){
67 Config cfg("NetworkSetup");
68 cfg.writeEntry("Profiles", profiles.join(" "));
69 }
59} 70}
60 71
61void MainWindowImp::loadModules(QString path){ 72void MainWindowImp::loadModules(QString path){
62} 73}
63 74
64/** 75/**
65 * Attempt to load a function and resolve a function. 76 * Attempt to load a function and resolve a function.
66 * @param pluginFileName - the name of the file in which to attempt to load 77 * @param pluginFileName - the name of the file in which to attempt to load
67 * @param resolveString - function pointer to resolve 78 * @param resolveString - function pointer to resolve
68 * @return pointer to the function with name resolveString or NULL 79 * @return pointer to the function with name resolveString or NULL
69 */ 80 */
70Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 81Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
71 //qDebug(pluginFileName.latin1()); 82 //qDebug(pluginFileName.latin1());
72 QLibrary *lib = new QLibrary(pluginFileName); 83 QLibrary *lib = new QLibrary(pluginFileName);
73 void *functionPointer = lib->resolve(resolveString); 84 void *functionPointer = lib->resolve(resolveString);
74 if( !functionPointer ){ 85 if( !functionPointer ){
75 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 86 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
76 delete lib; 87 delete lib;
77 return NULL; 88 return NULL;
78 } 89 }
79 90
80 // Try to get an object. 91 // Try to get an object.
81 Module *object = ((Module* (*)()) functionPointer)(); 92 Module *object = ((Module* (*)()) functionPointer)();
82 if(object == NULL){ 93 if(object == NULL){
83 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 94 qDebug("MainWindowImp: Couldn't create object, but did load library!");
84 delete lib; 95 delete lib;
85 return NULL; 96 return NULL;
86 } 97 }
87 98
88 // Store for reference 99 // Store for reference
89 libraries.insert(object, lib); 100 libraries.insert(object, lib);
90 return object; 101 return object;
91} 102}
92 103
93/* 104/*
94QList<QString> MainWindowImp::retrieveUnloadedPluginList(){ 105QList<QString> MainWindowImp::retrieveUnloadedPluginList(){
95 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ; 106 QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
96 QString path = DirStr + "plugins"; 107 QString path = DirStr + "plugins";
97 QDir d(path); 108 QDir d(path);
98 d.setFilter( QDir::Files | QDir::Hidden ); 109 d.setFilter( QDir::Files | QDir::Hidden );
99 110
100 QMap<QObject*, QLibrary*>::Iterator libraryIt; 111 QMap<QObject*, QLibrary*>::Iterator libraryIt;
101 QList<QString> rlist; 112 QList<QString> rlist;
102 rlist.setAutoDelete(false); 113 rlist.setAutoDelete(false);
103 114
104 const QFileInfoList *list = d.entryInfoList(); 115 const QFileInfoList *list = d.entryInfoList();
105 QFileInfoListIterator it( *list ); 116 QFileInfoListIterator it( *list );
106 QFileInfo *fi; 117 QFileInfo *fi;
107 while ( (fi=it.current()) ) { 118 while ( (fi=it.current()) ) {
108 if(fi->fileName().contains(".so")){ 119 if(fi->fileName().contains(".so")){
109 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt ) 120 for( libraryIt = libraries.begin(); libraryIt != libraries.end(); ++libraryIt )
110 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){ 121 if((path + "/" + fi->fileName()) != (libraryIt.data())->library()){
111 QString *s = new QString(path + "/" + fi->fileName()); 122 QString *s = new QString(path + "/" + fi->fileName());
112 rlist.append(s); 123 rlist.append(s);
113 } 124 }
114 } 125 }
115 ++it; 126 ++it;
116 } 127 }
117 return rlist; 128 return rlist;
118} 129}
119*/ 130*/
120 131
121/** 132/**
122 * The Add button was clicked. Bring up the add dialog and if OK is hit 133 * The Add button was clicked. Bring up the add dialog and if OK is hit
123 * load the plugin and append it to the list 134 * load the plugin and append it to the list
124 */ 135 */
125void MainWindowImp::addClicked(){ 136void MainWindowImp::addClicked(){
126 // Now that we have a list of all of the protocals, list them. 137 // Now that we have a list of all of the protocals, list them.
127 { 138 {
128 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok"); 139 QMessageBox::information(this, "No Modules", "Nothing to add.", "Ok");
129 return; 140 return;
130 } 141 }
131 AddServiceImp service(this, "AddService", true); 142 AddServiceImp service(this, "AddService", true);
132 service.showMaximized(); 143 service.showMaximized();
133 service.exec(); 144 service.exec();
134} 145}
135 146
136/** 147/**
137 * Prompt the user to see if they really want to do this. 148 * Prompt the user to see if they really want to do this.
138 * If they do then remove from the list and unload. 149 * If they do then remove from the list and unload.
139 */ 150 */
140void MainWindowImp::removeClicked(){ 151void MainWindowImp::removeClicked(){
141 QListViewItem *item = serviceList->currentItem(); 152 QListViewItem *item = serviceList->currentItem();
142 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 153 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
143 154
144 if(modules.find(interfaceItems[item]) == modules.end()){ 155 if(modules.find(interfaceItems[item]) == modules.end()){
145 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 156 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
146 } 157 }
147 else{ 158 else{
148 // Try to remove. 159 // Try to remove.
149 } 160 }
150 161
151} 162}
152 163
153/** 164/**
154 * See if there is a configuration for the selected protocal. 165 * See if there is a configuration for the selected protocal.
155 * Prompt with errors. 166 * Prompt with errors.
156 */ 167 */
157void MainWindowImp::configureClicked(){ 168void MainWindowImp::configureClicked(){
158 QListViewItem *item = serviceList->currentItem(); 169 QListViewItem *item = serviceList->currentItem();
159 if(item == NULL) NO_SELECT_ERROR_AND_RETURN 170 if(item == NULL) NO_SELECT_ERROR_AND_RETURN
160 171
161 if(modules.find(interfaceItems[item]) == modules.end()){ 172 if(modules.find(interfaceItems[item]) == modules.end()){
162 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); 173 InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]);
163 conf->showMaximized(); 174 conf->showMaximized();
164 conf->show(); 175 conf->show();
165 } 176 }
166 else{ 177 else{
167 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); 178 InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration");
168 conf->show(); 179 conf->show();
169 } 180 }
170} 181}
171 182
172/** 183/**
173 * Pull up the information about the selected interface 184 * Pull up the information about the selected interface
174 * Report an error 185 * Report an error
175 */ 186 */
176void MainWindowImp::informationClicked(){ 187void MainWindowImp::informationClicked(){
177 QListViewItem *item = serviceList->currentItem(); 188 QListViewItem *item = serviceList->currentItem();
178 if(item == NULL)NO_SELECT_ERROR_AND_RETURN 189 if(item == NULL)NO_SELECT_ERROR_AND_RETURN
179 190
180 if(modules.find(interfaceItems[item]) == modules.end()){ 191 if(modules.find(interfaceItems[item]) == modules.end()){
181 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); 192 InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]);
182 i->showMaximized(); 193 i->showMaximized();
183 i->show(); 194 i->show();
184 } 195 }
185 else{ 196 else{
186 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); 197 QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB");
187 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); 198 InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true);
188 t->insertTab(i, "TCP/IP"); 199 t->insertTab(i, "TCP/IP");
189 t->show(); 200 t->show();
190 } 201 }
191} 202}
192 203
193/** 204/**
194 * Aquire the list of active interfaces from ifconfig 205 * Aquire the list of active interfaces from ifconfig
195 * Call ifconfig and ifconfig -a 206 * Call ifconfig and ifconfig -a
196 */ 207 */
197void MainWindowImp::getInterfaceList(){ 208void MainWindowImp::getInterfaceList(){
198 KShellProcess *processAll = new KShellProcess(); 209 KShellProcess *processAll = new KShellProcess();
199 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 210 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
200 connect(processAll, SIGNAL(processExited(KProcess *)), 211 connect(processAll, SIGNAL(processExited(KProcess *)),
201 this, SLOT(jobDone(KProcess *))); 212 this, SLOT(jobDone(KProcess *)));
202 threads.insert(processAll, TEMP_ALL); 213 threads.insert(processAll, TEMP_ALL);
203 processAll->start(KShellProcess::NotifyOnExit); 214 processAll->start(KShellProcess::NotifyOnExit);
204 215
205 KShellProcess *process = new KShellProcess(); 216 KShellProcess *process = new KShellProcess();
206 *process << "/sbin/ifconfig" << " > " TEMP_UP; 217 *process << "/sbin/ifconfig" << " > " TEMP_UP;
207 connect(process, SIGNAL(processExited(KProcess *)), 218 connect(process, SIGNAL(processExited(KProcess *)),
208 this, SLOT(jobDone(KProcess *))); 219 this, SLOT(jobDone(KProcess *)));
209 threads.insert(process, TEMP_UP); 220 threads.insert(process, TEMP_UP);
210 process->start(KShellProcess::NotifyOnExit); 221 process->start(KShellProcess::NotifyOnExit);
211} 222}
212 223
213void MainWindowImp::jobDone(KProcess *process){ 224void MainWindowImp::jobDone(KProcess *process){
214 QString fileName = threads[process]; 225 QString fileName = threads[process];
215 threads.remove(process); 226 threads.remove(process);
216 delete process; 227 delete process;
217 228
218 QFile file(fileName); 229 QFile file(fileName);
219 if (!file.open(IO_ReadOnly)){ 230 if (!file.open(IO_ReadOnly)){
220 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 231 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
221 return; 232 return;
222 } 233 }
223 234
224 QTextStream stream( &file ); 235 QTextStream stream( &file );
225 QString line; 236 QString line;
226 while ( !stream.eof() ) { 237 while ( !stream.eof() ) {
227 line = stream.readLine(); 238 line = stream.readLine();
228 int space = line.find(" "); 239 int space = line.find(" ");
229 if(space > 1){ 240 if(space > 1){
230 // We have found an interface 241 // We have found an interface
231 QString interfaceName = line.mid(0, space); 242 QString interfaceName = line.mid(0, space);
232 Interface *i; 243 Interface *i;
233 // See if we already have it 244 // See if we already have it
234 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 245 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
235 if(fileName == TEMP_ALL) 246 if(fileName == TEMP_ALL)
236 i = new Interface(interfaceName, false); 247 i = new Interface(interfaceName, false);
237 else 248 else
238 i = new Interface(interfaceName, true); 249 i = new Interface(interfaceName, true);
239 } 250 }
240 else{ 251 else{
241 i = interfaceNames[interfaceName]; 252 i = interfaceNames[interfaceName];
242 if(fileName != TEMP_ALL) 253 if(fileName != TEMP_ALL)
243 i->setStatus(true); 254 i->setStatus(true);
244 } 255 }
245 256
246 i->setAttached(true); 257 i->setAttached(true);
247 i->setInterfaceName(interfaceName); 258 i->setInterfaceName(interfaceName);
248 259
249 QString hardName = "Ethernet"; 260 QString hardName = "Ethernet";
250 int hardwareName = line.find("Link encap:"); 261 int hardwareName = line.find("Link encap:");
251 int macAddress = line.find("HWaddr"); 262 int macAddress = line.find("HWaddr");
252 if(macAddress == -1) 263 if(macAddress == -1)
253 macAddress = line.length(); 264 macAddress = line.length();
254 if(hardwareName != -1) 265 if(hardwareName != -1)
255 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11))); 266 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
256 // We have found an interface 267 // We have found an interface
257 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 268 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
258 interfaceNames.insert(i->getInterfaceName(), i); 269 interfaceNames.insert(i->getInterfaceName(), i);
259 updateInterface(i); 270 updateInterface(i);
260 } 271 }
261 } 272 }
262 file.close(); 273 file.close();
263 QFile::remove(fileName); 274 QFile::remove(fileName);
264} 275}
265 276
266void MainWindowImp::updateInterface(Interface *i){ 277void MainWindowImp::updateInterface(Interface *i){
267 QListViewItem *item = NULL; 278 QListViewItem *item = NULL;
268 279
269 // See if we already have it 280 // See if we already have it
270 if(items.find(i) == items.end()){ 281 if(items.find(i) == items.end()){
271 item = new QListViewItem(serviceList, "", "", ""); 282 item = new QListViewItem(serviceList, "", "", "");
272 // See if you can't find a module owner for this interface 283 // See if you can't find a module owner for this interface
273 //EmployeeMap::Iterator it; 284 //EmployeeMap::Iterator it;
274 //for( it = map.begin(); it != map.end(); ++it ) 285 //for( it = map.begin(); it != map.end(); ++it )
275 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); 286 // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() );
276 287
277 items.insert(i, item); 288 items.insert(i, item);
278 interfaceItems.insert(item, i); 289 interfaceItems.insert(item, i);
279 } 290 }
280 else 291 else
281 item = items[i]; 292 item = items[i];
282 293
283 QString statusImage = "down"; 294 QString statusImage = "down";
284 if(i->getStatus()) 295 if(i->getStatus())
285 statusImage = "up"; 296 statusImage = "up";
286 QPixmap status = (Resource::loadPixmap(statusImage)); 297 QPixmap status = (Resource::loadPixmap(statusImage));
287 item->setPixmap(0, status); 298 item->setPixmap(0, status);
288 299
289 QString typeName = "lan"; 300 QString typeName = "lan";
290 if(i->getHardwareName().contains("Local Loopback")) 301 if(i->getHardwareName().contains("Local Loopback"))
291 typeName = "lo"; 302 typeName = "lo";
292 QPixmap type = (Resource::loadPixmap(typeName)); 303 QPixmap type = (Resource::loadPixmap(typeName));
293 item->setPixmap(1, type); 304 item->setPixmap(1, type);
294 305
295 item->setText(2, i->getHardwareName()); 306 item->setText(2, i->getHardwareName());
296 307
297} 308}
298 309
299void MainWindowImp::addProfile(){ 310void MainWindowImp::addProfile(){
300 311
301} 312}
302 313
303void MainWindowImp::removeProfile(){ 314void MainWindowImp::removeProfile(){
304 315
305} 316}
306 317
307// mainwindowimp.cpp 318// mainwindowimp.cpp
308 319
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 95ec2a1..0618dd2 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,53 +1,56 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include "module.h"
6#include "interface.h"
7#include "kprocess.h"
8#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h>
9 7
8class Module;
9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess;
11 12
12class MainWindowImp : public MainWindow { 13class MainWindowImp : public MainWindow {
13 Q_OBJECT 14 Q_OBJECT
14 15
15public: 16public:
16 MainWindowImp(QWidget *parent=0, const char *name=0); 17 MainWindowImp(QWidget *parent=0, const char *name=0);
17 ~MainWindowImp(); 18 ~MainWindowImp();
18 19
19private slots: 20private slots:
20 void addClicked(); 21 void addClicked();
21 void removeClicked(); 22 void removeClicked();
22 void configureClicked(); 23 void configureClicked();
23 void informationClicked(); 24 void informationClicked();
24 25
25 void jobDone(KProcess *process); 26 void jobDone(KProcess *process);
26 void getInterfaceList(); 27 void getInterfaceList();
27 28
28 void addProfile(); 29 void addProfile();
29 void removeProfile(); 30 void removeProfile();
30 31
31 void updateInterface(Interface *i); 32 void updateInterface(Interface *i);
32 33
33private: 34private:
34 void loadModules(QString path); 35 void loadModules(QString path);
35 36
36 Module* loadPlugin(QString pluginFileName, 37 Module* loadPlugin(QString pluginFileName,
37 QString resolveString = "create_plugin"); 38 QString resolveString = "create_plugin");
38 39
39 // For our local list of names 40 // For our local list of names
40 QMap<QString, Interface*> interfaceNames; 41 QMap<QString, Interface*> interfaceNames;
41 42
42 QMap<Module*, QLibrary*> libraries; 43 QMap<Module*, QLibrary*> libraries;
43 QMap<Interface*, Module*> modules; 44 QMap<Interface*, Module*> modules;
44 QMap<Interface*, QListViewItem*> items; 45 QMap<Interface*, QListViewItem*> items;
45 QMap<QListViewItem*, Interface*> interfaceItems; 46 QMap<QListViewItem*, Interface*> interfaceItems;
46 47
47 QMap<KProcess*, QString> threads; 48 QMap<KProcess*, QString> threads;
49 QStringList profiles;
50
48}; 51};
49 52
50#endif 53#endif
51 54
52// mainwindowimp.h 55// mainwindowimp.h
53 56