summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-02 18:52:50 (UTC)
committer benmeyer <benmeyer>2002-10-02 18:52:50 (UTC)
commit56a0a990842a5b57b961c064809aae27f087562d (patch) (unidiff)
treee16ec644bff60c88c710ef6beedc5b033b39624c
parent527e77d8244fb25d0bab39857eebbdfbcbfb807a (diff)
downloadopie-56a0a990842a5b57b961c064809aae27f087562d.zip
opie-56a0a990842a5b57b961c064809aae27f087562d.tar.gz
opie-56a0a990842a5b57b961c064809aae27f087562d.tar.bz2
DHCP works, addProfile works
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interface.cpp16
-rw-r--r--noncore/net/networksetup/mainwindow.ui16
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp73
-rw-r--r--noncore/net/networksetup/networksetup.pro4
-rw-r--r--noncore/settings/networksettings/interface.cpp16
-rw-r--r--noncore/settings/networksettings/mainwindow.ui16
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp73
-rw-r--r--noncore/settings/networksettings/networksetup.pro4
8 files changed, 148 insertions, 70 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index 5b21364..1f32093 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -1,11 +1,12 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h>
4#include <qfileinfo.h> 5#include <qfileinfo.h>
5#include <qtextstream.h> 6#include <qtextstream.h>
6 7
7#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
8#define HDCP_INFO_DIR "/etc/dhcpc" 9#define HDCP_INFO_DIR "/etc/dhcpc"
9 10
10#include <stdio.h> 11#include <stdio.h>
11#include <stdlib.h> 12#include <stdlib.h>
@@ -122,19 +123,24 @@ bool Interface::refresh(){
122 QFile::remove(fileName); 123 QFile::remove(fileName);
123 124
124 // DHCP TESTING 125 // DHCP TESTING
125 // reset DHCP info 126 // reset DHCP info
126 dhcpServerIp = ""; 127 dhcpServerIp = "";
127 leaseObtained = ""; 128 leaseObtained = "";
128 leaseExpires = ""; 129 leaseExpires = "";
129 dhcp = false; 130 dhcp = false;
130 131
132 QString dhcpDirectory(HDCP_INFO_DIR);
133 QDir d(dhcpDirectory);
134 if(!d.exists(dhcpDirectory))
135 dhcpDirectory = "/var/run";
136
131 // See if we have 137 // See if we have
132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); 138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
133 // If there is no DHCP information then exit now with no errors. 139 // If there is no DHCP information then exit now with no errors.
134 if(!QFile::exists(dhcpFile)){ 140 if(!QFile::exists(dhcpFile)){
135 return true; 141 return true;
136 } 142 }
137 143
138 file.setName(dhcpFile); 144 file.setName(dhcpFile);
139 if (!file.open(IO_ReadOnly)){ 145 if (!file.open(IO_ReadOnly)){
140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 146 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
@@ -143,29 +149,29 @@ bool Interface::refresh(){
143 149
144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 150 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
145 int leaseTime = 0; 151 int leaseTime = 0;
146 int renewalTime = 0; 152 int renewalTime = 0;
147 153
148 stream.setDevice( &file ); 154 stream.setDevice( &file );
149 while ( !stream.eof() ) { 155 while ( !stream.eof() ) {
150 line = stream.readLine(); 156 line = stream.readLine();
151 if(line.contains("DHCPSID=")) 157 if(line.contains("DHCPSIADDR="))
152 dhcpServerIp = line.mid(8, line.length()); 158 dhcpServerIp = line.mid(11, line.length());
153 if(line.contains("LEASETIME=")) 159 if(line.contains("LEASETIME="))
154 leaseTime = line.mid(10, line.length()).toInt(); 160 leaseTime = line.mid(10, line.length()).toInt();
155 if(line.contains("RENEWALTIME=")) 161 if(line.contains("RENEWALTIME="))
156 renewalTime = line.mid(12, line.length()).toInt(); 162 renewalTime = line.mid(12, line.length()).toInt();
157 } 163 }
158 file.close(); 164 file.close();
159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 165 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 166 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
161 167
162 // Get the pid of the deamond 168 // Get the pid of the deamond
163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); 169 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
164 file.setName(dhcpFile); 170 file.setName(dhcpFile);
165 if (!file.open(IO_ReadOnly)){ 171 if (!file.open(IO_ReadOnly)){
166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 172 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
167 return false; 173 return false;
168 } 174 }
169 175
170 int pid = -1; 176 int pid = -1;
171 stream.setDevice( &file ); 177 stream.setDevice( &file );
diff --git a/noncore/net/networksetup/mainwindow.ui b/noncore/net/networksetup/mainwindow.ui
index f5b104a..3538aeb 100644
--- a/noncore/net/networksetup/mainwindow.ui
+++ b/noncore/net/networksetup/mainwindow.ui
@@ -40,17 +40,17 @@
40 <widget> 40 <widget>
41 <class>QWidget</class> 41 <class>QWidget</class>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>name</name> 43 <name>name</name>
44 <cstring>Widget3</cstring> 44 <cstring>Widget3</cstring>
45 </property> 45 </property>
46 <attribute> 46 <attribute>
47 <name>title</name> 47 <name>title</name>
48 <string>Interfaces</string> 48 <string>Connections</string>
49 </attribute> 49 </attribute>
50 <vbox> 50 <vbox>
51 <property stdset="1"> 51 <property stdset="1">
52 <name>margin</name> 52 <name>margin</name>
53 <number>0</number> 53 <number>0</number>
54 </property> 54 </property>
55 <property stdset="1"> 55 <property stdset="1">
56 <name>spacing</name> 56 <name>spacing</name>
@@ -95,16 +95,30 @@
95 <name>clickable</name> 95 <name>clickable</name>
96 <bool>true</bool> 96 <bool>true</bool>
97 </property> 97 </property>
98 <property> 98 <property>
99 <name>resizeable</name> 99 <name>resizeable</name>
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <column>
104 <property>
105 <name>text</name>
106 <string>IP</string>
107 </property>
108 <property>
109 <name>clickable</name>
110 <bool>true</bool>
111 </property>
112 <property>
113 <name>resizeable</name>
114 <bool>true</bool>
115 </property>
116 </column>
103 <property stdset="1"> 117 <property stdset="1">
104 <name>name</name> 118 <name>name</name>
105 <cstring>connectionList</cstring> 119 <cstring>connectionList</cstring>
106 </property> 120 </property>
107 <property stdset="1"> 121 <property stdset="1">
108 <name>allColumnsShowFocus</name> 122 <name>allColumnsShowFocus</name>
109 <bool>true</bool> 123 <bool>true</bool>
110 </property> 124 </property>
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 66ec8b5..e9429e3 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,15 +1,16 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "module.h" 5#include "module.h"
6 6
7#include "kprocess.h" 7#include "kprocess.h"
8#include "namedialog.h"
8 9
9#include <qpushbutton.h> 10#include <qpushbutton.h>
10#include <qtabwidget.h> 11#include <qtabwidget.h>
11#include <qlistbox.h> 12#include <qlistbox.h>
12#include <qlistview.h> 13#include <qlistview.h>
13#include <qheader.h> 14#include <qheader.h>
14#include <qlabel.h> 15#include <qlabel.h>
15 16
@@ -123,53 +124,73 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
123 124
124/** 125/**
125 * The Add button was clicked. Bring up the add dialog and if OK is hit 126 * The Add button was clicked. Bring up the add dialog and if OK is hit
126 * load the plugin and append it to the list 127 * load the plugin and append it to the list
127 */ 128 */
128void MainWindowImp::addClicked(){ 129void MainWindowImp::addClicked(){
129 QMap<Module*, QLibrary*>::Iterator it; 130 QMap<Module*, QLibrary*>::Iterator it;
130 QMap<QString, QString> list; 131 QMap<QString, QString> list;
132 QMap<QString, Module*> newInterfaceOwners;
131 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 133 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
132 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 134 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
133 for( it = libraries.begin(); it != libraries.end(); ++it ){ 135 for( it = libraries.begin(); it != libraries.end(); ++it ){
134 if(it.key()) 136 if(it.key()){
135 (it.key())->possibleNewInterfaces(list); 137 (it.key())->possibleNewInterfaces(list);
138 }
136 } 139 }
137 // See if the list has anything that we can add. 140 // See if the list has anything that we can add.
138 if(list.count() == 0){ 141 if(list.count() == 0){
139 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 142 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
140 return; 143 return;
141 } 144 }
142 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 145 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
143 addNewConnection.addConnections(list); 146 addNewConnection.addConnections(list);
144 addNewConnection.showMaximized(); 147 addNewConnection.showMaximized();
145 if(QDialog::Accepted == addNewConnection.exec()){ 148 if(QDialog::Accepted == addNewConnection.exec()){
146 149 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
150 if(!item)
151 return;
152
153 for( it = libraries.begin(); it != libraries.end(); ++it ){
154 if(it.key()){
155 Interface *i = (it.key())->addNewInterface(item->text(0));
156 if(i){
157 interfaceNames.insert(i->getInterfaceName(), i);
158 updateInterface(i);
159 }
160 }
161 }
147 } 162 }
148} 163}
149 164
150/** 165/**
151 * Prompt the user to see if they really want to do this. 166 * Prompt the user to see if they really want to do this.
152 * If they do then remove from the list and unload. 167 * If they do then remove from the list and unload.
153 */ 168 */
154void MainWindowImp::removeClicked(){ 169void MainWindowImp::removeClicked(){
155 QListViewItem *item = connectionList->currentItem(); 170 QListViewItem *item = connectionList->currentItem();
156 if(item == NULL) { 171 if(!item) {
157 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 172 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
158 return; 173 return;
159 } 174 }
160 175
161 if((interfaceItems[item])->getModuleOwner() == NULL){ 176 Interface *i = interfaceItems[item];
177 if(i->getModuleOwner() == NULL){
162 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 178 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
163 } 179 }
164 else{ 180 else{
165 // Try to remove. 181 if(!i->getModuleOwner()->remove(i))
182 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
183 else{
184 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
185 // TODO memory managment....
186 // who deletes the interface?
187 }
166 } 188 }
167
168} 189}
169 190
170/** 191/**
171 * Pull up the configure about the currently selected interface. 192 * Pull up the configure about the currently selected interface.
172 * Report an error if no interface is selected. 193 * Report an error if no interface is selected.
173 * If the interface has a module owner then request its configure with a empty 194 * If the interface has a module owner then request its configure with a empty
174 * tab. If tab is !NULL then append the interfaces setup widget to it. 195 * tab. If tab is !NULL then append the interfaces setup widget to it.
175 */ 196 */
@@ -306,75 +327,73 @@ void MainWindowImp::jobDone(KProcess *process){
306 updateInterface(i); 327 updateInterface(i);
307 } 328 }
308 } 329 }
309 file.close(); 330 file.close();
310 QFile::remove(fileName); 331 QFile::remove(fileName);
311} 332}
312 333
313/** 334/**
314 * 335 * Update this interface. If no QListViewItem exists create one.
336 * @param Interface* pointer to the interface that needs to be updated.
315 */ 337 */
316void MainWindowImp::updateInterface(Interface *i){ 338void MainWindowImp::updateInterface(Interface *i){
317 QListViewItem *item = NULL; 339 QListViewItem *item = NULL;
318 340
319 // See if we already have it 341 // Find the interface, making it if needed.
320 if(items.find(i) == items.end()){ 342 if(items.find(i) == items.end()){
321 item = new QListViewItem(connectionList, "", "", ""); 343 item = new QListViewItem(connectionList, "", "", "");
322 // See if you can't find a module owner for this interface 344 // See if you can't find a module owner for this interface
323 QMap<Module*, QLibrary*>::Iterator it; 345 QMap<Module*, QLibrary*>::Iterator it;
324 for( it = libraries.begin(); it != libraries.end(); ++it ){ 346 for( it = libraries.begin(); it != libraries.end(); ++it ){
325 if(it.key()->isOwner(i)) 347 if(it.key()->isOwner(i))
326 i->setModuleOwner(it.key()); 348 i->setModuleOwner(it.key());
327 } 349 }
328
329 items.insert(i, item); 350 items.insert(i, item);
330 interfaceItems.insert(item, i); 351 interfaceItems.insert(item, i);
331 } 352 }
332 else 353 else
333 item = items[i]; 354 item = items[i];
334 355
335 QString statusImage = "down"; 356 // Update the icons and information
336 if(i->getStatus()) 357 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
337 statusImage = "up";
338 QPixmap status = (Resource::loadPixmap(statusImage));
339 item->setPixmap(0, status);
340 358
341 QString typeName = "lan"; 359 QString typeName = "lan";
342 if(i->getHardwareName().contains("Local Loopback")) 360 if(i->getHardwareName().contains("Local Loopback"))
343 typeName = "lo"; 361 typeName = "lo";
344 if(i->getInterfaceName().contains("irda")) 362 if(i->getInterfaceName().contains("irda"))
345 typeName = "irda"; 363 typeName = "irda";
346 if(i->getInterfaceName().contains("wlan")) 364 if(i->getInterfaceName().contains("wlan"))
347 typeName = "wlan"; 365 typeName = "wlan";
348 // Actually try to use the Module 366 // Actually try to use the Module
349 if(i->getModuleOwner() != NULL){ 367 if(i->getModuleOwner() != NULL)
350 typeName = i->getModuleOwner()->getPixmapName(i); 368 typeName = i->getModuleOwner()->getPixmapName(i);
351 }
352 QPixmap type = (Resource::loadPixmap(typeName));
353 item->setPixmap(1, type);
354
355 item->setText(2, i->getHardwareName());
356 369
370 item->setPixmap(1, (Resource::loadPixmap(typeName)));
371 item->setText(2, i->getHardwareName());
372 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
357} 373}
358 374
359/** 375/**
360 * Adds a new profile to the list of profiles. 376 * Adds a new profile to the list of profiles.
361 * Don't add profiles that already exists. 377 * Don't add profiles that already exists.
362 * Appends to the combo and QStringList 378 * Appends to the list and QStringList
363 */ 379 */
364void MainWindowImp::addProfile(){ 380void MainWindowImp::addProfile(){
365 QString newProfileName = "New"; 381 NameDialog foo(this, "namedialog", true);
382 QString newProfileName = foo.go();
383 if(newProfileName.length() == 0)
384 return;
385
366 if(profiles.grep(newProfileName).count() > 0){ 386 if(profiles.grep(newProfileName).count() > 0){
367 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok"); 387 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
368 return; 388 return;
369 } 389 }
370 profiles.append(newProfileName); 390 profiles.append(newProfileName);
371 profilesList->insertItem(newProfileName); 391 profilesList->insertItem(newProfileName);
372
373} 392}
374 393
375/** 394/**
376 * Removes the currently selected profile in the combo. 395 * Removes the currently selected profile in the combo.
377 * Doesn't delete if there are less then 2 profiles. 396 * Doesn't delete if there are less then 2 profiles.
378 */ 397 */
379void MainWindowImp::removeProfile(){ 398void MainWindowImp::removeProfile(){
380 if(profilesList->count() <= 1){ 399 if(profilesList->count() <= 1){
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro
index ba70180..e146eb4 100644
--- a/noncore/net/networksetup/networksetup.pro
+++ b/noncore/net/networksetup/networksetup.pro
@@ -1,10 +1,10 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 4 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h namedialog.h
5 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 5 SOURCES = main.cpp namedialog.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
6 #INCLUDEPATH+= $(QPEDIR)/include 6 #INCLUDEPATH+= $(QPEDIR)/include
7 #DEPENDPATH+= $(QPEDIR)/include 7 #DEPENDPATH+= $(QPEDIR)/include
8LIBS += -lqpe 8LIBS += -lqpe
9 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 9 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
10 TARGET = networksetup 10 TARGET = networksetup
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index 5b21364..1f32093 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -1,11 +1,12 @@
1#include "interface.h" 1#include "interface.h"
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qdir.h>
4#include <qfileinfo.h> 5#include <qfileinfo.h>
5#include <qtextstream.h> 6#include <qtextstream.h>
6 7
7#define IFCONFIG "/sbin/ifconfig" 8#define IFCONFIG "/sbin/ifconfig"
8#define HDCP_INFO_DIR "/etc/dhcpc" 9#define HDCP_INFO_DIR "/etc/dhcpc"
9 10
10#include <stdio.h> 11#include <stdio.h>
11#include <stdlib.h> 12#include <stdlib.h>
@@ -122,19 +123,24 @@ bool Interface::refresh(){
122 QFile::remove(fileName); 123 QFile::remove(fileName);
123 124
124 // DHCP TESTING 125 // DHCP TESTING
125 // reset DHCP info 126 // reset DHCP info
126 dhcpServerIp = ""; 127 dhcpServerIp = "";
127 leaseObtained = ""; 128 leaseObtained = "";
128 leaseExpires = ""; 129 leaseExpires = "";
129 dhcp = false; 130 dhcp = false;
130 131
132 QString dhcpDirectory(HDCP_INFO_DIR);
133 QDir d(dhcpDirectory);
134 if(!d.exists(dhcpDirectory))
135 dhcpDirectory = "/var/run";
136
131 // See if we have 137 // See if we have
132 QString dhcpFile(QString(HDCP_INFO_DIR "/dhcpcd-%1.info").arg(interfaceName)); 138 QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(interfaceName));
133 // If there is no DHCP information then exit now with no errors. 139 // If there is no DHCP information then exit now with no errors.
134 if(!QFile::exists(dhcpFile)){ 140 if(!QFile::exists(dhcpFile)){
135 return true; 141 return true;
136 } 142 }
137 143
138 file.setName(dhcpFile); 144 file.setName(dhcpFile);
139 if (!file.open(IO_ReadOnly)){ 145 if (!file.open(IO_ReadOnly)){
140 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 146 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
@@ -143,29 +149,29 @@ bool Interface::refresh(){
143 149
144 // leaseTime and renewalTime and used if pid and deamon exe can be accessed. 150 // leaseTime and renewalTime and used if pid and deamon exe can be accessed.
145 int leaseTime = 0; 151 int leaseTime = 0;
146 int renewalTime = 0; 152 int renewalTime = 0;
147 153
148 stream.setDevice( &file ); 154 stream.setDevice( &file );
149 while ( !stream.eof() ) { 155 while ( !stream.eof() ) {
150 line = stream.readLine(); 156 line = stream.readLine();
151 if(line.contains("DHCPSID=")) 157 if(line.contains("DHCPSIADDR="))
152 dhcpServerIp = line.mid(8, line.length()); 158 dhcpServerIp = line.mid(11, line.length());
153 if(line.contains("LEASETIME=")) 159 if(line.contains("LEASETIME="))
154 leaseTime = line.mid(10, line.length()).toInt(); 160 leaseTime = line.mid(10, line.length()).toInt();
155 if(line.contains("RENEWALTIME=")) 161 if(line.contains("RENEWALTIME="))
156 renewalTime = line.mid(12, line.length()).toInt(); 162 renewalTime = line.mid(12, line.length()).toInt();
157 } 163 }
158 file.close(); 164 file.close();
159 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); 165 //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1());
160 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); 166 //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1());
161 167
162 // Get the pid of the deamond 168 // Get the pid of the deamond
163 dhcpFile = (QString(HDCP_INFO_DIR "/dhcpcd-%1.pid").arg(interfaceName)); 169 dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(interfaceName));
164 file.setName(dhcpFile); 170 file.setName(dhcpFile);
165 if (!file.open(IO_ReadOnly)){ 171 if (!file.open(IO_ReadOnly)){
166 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); 172 qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1());
167 return false; 173 return false;
168 } 174 }
169 175
170 int pid = -1; 176 int pid = -1;
171 stream.setDevice( &file ); 177 stream.setDevice( &file );
diff --git a/noncore/settings/networksettings/mainwindow.ui b/noncore/settings/networksettings/mainwindow.ui
index f5b104a..3538aeb 100644
--- a/noncore/settings/networksettings/mainwindow.ui
+++ b/noncore/settings/networksettings/mainwindow.ui
@@ -40,17 +40,17 @@
40 <widget> 40 <widget>
41 <class>QWidget</class> 41 <class>QWidget</class>
42 <property stdset="1"> 42 <property stdset="1">
43 <name>name</name> 43 <name>name</name>
44 <cstring>Widget3</cstring> 44 <cstring>Widget3</cstring>
45 </property> 45 </property>
46 <attribute> 46 <attribute>
47 <name>title</name> 47 <name>title</name>
48 <string>Interfaces</string> 48 <string>Connections</string>
49 </attribute> 49 </attribute>
50 <vbox> 50 <vbox>
51 <property stdset="1"> 51 <property stdset="1">
52 <name>margin</name> 52 <name>margin</name>
53 <number>0</number> 53 <number>0</number>
54 </property> 54 </property>
55 <property stdset="1"> 55 <property stdset="1">
56 <name>spacing</name> 56 <name>spacing</name>
@@ -95,16 +95,30 @@
95 <name>clickable</name> 95 <name>clickable</name>
96 <bool>true</bool> 96 <bool>true</bool>
97 </property> 97 </property>
98 <property> 98 <property>
99 <name>resizeable</name> 99 <name>resizeable</name>
100 <bool>true</bool> 100 <bool>true</bool>
101 </property> 101 </property>
102 </column> 102 </column>
103 <column>
104 <property>
105 <name>text</name>
106 <string>IP</string>
107 </property>
108 <property>
109 <name>clickable</name>
110 <bool>true</bool>
111 </property>
112 <property>
113 <name>resizeable</name>
114 <bool>true</bool>
115 </property>
116 </column>
103 <property stdset="1"> 117 <property stdset="1">
104 <name>name</name> 118 <name>name</name>
105 <cstring>connectionList</cstring> 119 <cstring>connectionList</cstring>
106 </property> 120 </property>
107 <property stdset="1"> 121 <property stdset="1">
108 <name>allColumnsShowFocus</name> 122 <name>allColumnsShowFocus</name>
109 <bool>true</bool> 123 <bool>true</bool>
110 </property> 124 </property>
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 66ec8b5..e9429e3 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,15 +1,16 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "module.h" 5#include "module.h"
6 6
7#include "kprocess.h" 7#include "kprocess.h"
8#include "namedialog.h"
8 9
9#include <qpushbutton.h> 10#include <qpushbutton.h>
10#include <qtabwidget.h> 11#include <qtabwidget.h>
11#include <qlistbox.h> 12#include <qlistbox.h>
12#include <qlistview.h> 13#include <qlistview.h>
13#include <qheader.h> 14#include <qheader.h>
14#include <qlabel.h> 15#include <qlabel.h>
15 16
@@ -123,53 +124,73 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString)
123 124
124/** 125/**
125 * The Add button was clicked. Bring up the add dialog and if OK is hit 126 * The Add button was clicked. Bring up the add dialog and if OK is hit
126 * load the plugin and append it to the list 127 * load the plugin and append it to the list
127 */ 128 */
128void MainWindowImp::addClicked(){ 129void MainWindowImp::addClicked(){
129 QMap<Module*, QLibrary*>::Iterator it; 130 QMap<Module*, QLibrary*>::Iterator it;
130 QMap<QString, QString> list; 131 QMap<QString, QString> list;
132 QMap<QString, Module*> newInterfaceOwners;
131 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 133 list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
132 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 134 list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
133 for( it = libraries.begin(); it != libraries.end(); ++it ){ 135 for( it = libraries.begin(); it != libraries.end(); ++it ){
134 if(it.key()) 136 if(it.key()){
135 (it.key())->possibleNewInterfaces(list); 137 (it.key())->possibleNewInterfaces(list);
138 }
136 } 139 }
137 // See if the list has anything that we can add. 140 // See if the list has anything that we can add.
138 if(list.count() == 0){ 141 if(list.count() == 0){
139 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); 142 QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok");
140 return; 143 return;
141 } 144 }
142 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 145 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
143 addNewConnection.addConnections(list); 146 addNewConnection.addConnections(list);
144 addNewConnection.showMaximized(); 147 addNewConnection.showMaximized();
145 if(QDialog::Accepted == addNewConnection.exec()){ 148 if(QDialog::Accepted == addNewConnection.exec()){
146 149 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
150 if(!item)
151 return;
152
153 for( it = libraries.begin(); it != libraries.end(); ++it ){
154 if(it.key()){
155 Interface *i = (it.key())->addNewInterface(item->text(0));
156 if(i){
157 interfaceNames.insert(i->getInterfaceName(), i);
158 updateInterface(i);
159 }
160 }
161 }
147 } 162 }
148} 163}
149 164
150/** 165/**
151 * Prompt the user to see if they really want to do this. 166 * Prompt the user to see if they really want to do this.
152 * If they do then remove from the list and unload. 167 * If they do then remove from the list and unload.
153 */ 168 */
154void MainWindowImp::removeClicked(){ 169void MainWindowImp::removeClicked(){
155 QListViewItem *item = connectionList->currentItem(); 170 QListViewItem *item = connectionList->currentItem();
156 if(item == NULL) { 171 if(!item) {
157 QMessageBox::information(this, "Error","Please select an interface.", "Ok"); 172 QMessageBox::information(this, "Error","Please select an interface.", "Ok");
158 return; 173 return;
159 } 174 }
160 175
161 if((interfaceItems[item])->getModuleOwner() == NULL){ 176 Interface *i = interfaceItems[item];
177 if(i->getModuleOwner() == NULL){
162 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); 178 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok");
163 } 179 }
164 else{ 180 else{
165 // Try to remove. 181 if(!i->getModuleOwner()->remove(i))
182 QMessageBox::information(this, "Error", "Unable to remove.", "Ok");
183 else{
184 QMessageBox::information(this, "Success", "Interface was removed.", "Ok");
185 // TODO memory managment....
186 // who deletes the interface?
187 }
166 } 188 }
167
168} 189}
169 190
170/** 191/**
171 * Pull up the configure about the currently selected interface. 192 * Pull up the configure about the currently selected interface.
172 * Report an error if no interface is selected. 193 * Report an error if no interface is selected.
173 * If the interface has a module owner then request its configure with a empty 194 * If the interface has a module owner then request its configure with a empty
174 * tab. If tab is !NULL then append the interfaces setup widget to it. 195 * tab. If tab is !NULL then append the interfaces setup widget to it.
175 */ 196 */
@@ -306,75 +327,73 @@ void MainWindowImp::jobDone(KProcess *process){
306 updateInterface(i); 327 updateInterface(i);
307 } 328 }
308 } 329 }
309 file.close(); 330 file.close();
310 QFile::remove(fileName); 331 QFile::remove(fileName);
311} 332}
312 333
313/** 334/**
314 * 335 * Update this interface. If no QListViewItem exists create one.
336 * @param Interface* pointer to the interface that needs to be updated.
315 */ 337 */
316void MainWindowImp::updateInterface(Interface *i){ 338void MainWindowImp::updateInterface(Interface *i){
317 QListViewItem *item = NULL; 339 QListViewItem *item = NULL;
318 340
319 // See if we already have it 341 // Find the interface, making it if needed.
320 if(items.find(i) == items.end()){ 342 if(items.find(i) == items.end()){
321 item = new QListViewItem(connectionList, "", "", ""); 343 item = new QListViewItem(connectionList, "", "", "");
322 // See if you can't find a module owner for this interface 344 // See if you can't find a module owner for this interface
323 QMap<Module*, QLibrary*>::Iterator it; 345 QMap<Module*, QLibrary*>::Iterator it;
324 for( it = libraries.begin(); it != libraries.end(); ++it ){ 346 for( it = libraries.begin(); it != libraries.end(); ++it ){
325 if(it.key()->isOwner(i)) 347 if(it.key()->isOwner(i))
326 i->setModuleOwner(it.key()); 348 i->setModuleOwner(it.key());
327 } 349 }
328
329 items.insert(i, item); 350 items.insert(i, item);
330 interfaceItems.insert(item, i); 351 interfaceItems.insert(item, i);
331 } 352 }
332 else 353 else
333 item = items[i]; 354 item = items[i];
334 355
335 QString statusImage = "down"; 356 // Update the icons and information
336 if(i->getStatus()) 357 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
337 statusImage = "up";
338 QPixmap status = (Resource::loadPixmap(statusImage));
339 item->setPixmap(0, status);
340 358
341 QString typeName = "lan"; 359 QString typeName = "lan";
342 if(i->getHardwareName().contains("Local Loopback")) 360 if(i->getHardwareName().contains("Local Loopback"))
343 typeName = "lo"; 361 typeName = "lo";
344 if(i->getInterfaceName().contains("irda")) 362 if(i->getInterfaceName().contains("irda"))
345 typeName = "irda"; 363 typeName = "irda";
346 if(i->getInterfaceName().contains("wlan")) 364 if(i->getInterfaceName().contains("wlan"))
347 typeName = "wlan"; 365 typeName = "wlan";
348 // Actually try to use the Module 366 // Actually try to use the Module
349 if(i->getModuleOwner() != NULL){ 367 if(i->getModuleOwner() != NULL)
350 typeName = i->getModuleOwner()->getPixmapName(i); 368 typeName = i->getModuleOwner()->getPixmapName(i);
351 }
352 QPixmap type = (Resource::loadPixmap(typeName));
353 item->setPixmap(1, type);
354
355 item->setText(2, i->getHardwareName());
356 369
370 item->setPixmap(1, (Resource::loadPixmap(typeName)));
371 item->setText(2, i->getHardwareName());
372 item->setText(3, (i->getStatus()) ? i->getIp() : QString(""));
357} 373}
358 374
359/** 375/**
360 * Adds a new profile to the list of profiles. 376 * Adds a new profile to the list of profiles.
361 * Don't add profiles that already exists. 377 * Don't add profiles that already exists.
362 * Appends to the combo and QStringList 378 * Appends to the list and QStringList
363 */ 379 */
364void MainWindowImp::addProfile(){ 380void MainWindowImp::addProfile(){
365 QString newProfileName = "New"; 381 NameDialog foo(this, "namedialog", true);
382 QString newProfileName = foo.go();
383 if(newProfileName.length() == 0)
384 return;
385
366 if(profiles.grep(newProfileName).count() > 0){ 386 if(profiles.grep(newProfileName).count() > 0){
367 QMessageBox::information(this, "Can't Add.","Profile already exists.", "Ok"); 387 QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok");
368 return; 388 return;
369 } 389 }
370 profiles.append(newProfileName); 390 profiles.append(newProfileName);
371 profilesList->insertItem(newProfileName); 391 profilesList->insertItem(newProfileName);
372
373} 392}
374 393
375/** 394/**
376 * Removes the currently selected profile in the combo. 395 * Removes the currently selected profile in the combo.
377 * Doesn't delete if there are less then 2 profiles. 396 * Doesn't delete if there are less then 2 profiles.
378 */ 397 */
379void MainWindowImp::removeProfile(){ 398void MainWindowImp::removeProfile(){
380 if(profilesList->count() <= 1){ 399 if(profilesList->count() <= 1){
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro
index ba70180..e146eb4 100644
--- a/noncore/settings/networksettings/networksetup.pro
+++ b/noncore/settings/networksettings/networksetup.pro
@@ -1,10 +1,10 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h 4 HEADERS = mainwindowimp.h addconnectionimp.h interface.h interfaceinformationimp.h interfacesetupimp.h interfaces.h defaultmodule.h kprocctrl.h module.h kprocess.h namedialog.h
5 SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp 5 SOURCES = main.cpp namedialog.cpp mainwindowimp.cpp addconnectionimp.cpp interface.cpp interfaceinformationimp.cpp interfacesetupimp.cpp kprocctrl.cpp kprocess.cpp interfaces.cpp
6 #INCLUDEPATH+= $(QPEDIR)/include 6 #INCLUDEPATH+= $(QPEDIR)/include
7 #DEPENDPATH+= $(QPEDIR)/include 7 #DEPENDPATH+= $(QPEDIR)/include
8LIBS += -lqpe 8LIBS += -lqpe
9 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui 9 INTERFACES= mainwindow.ui addconnection.ui interfaceinformation.ui interfaceadvanced.ui interfacesetup.ui
10 TARGET = networksetup 10 TARGET = networksetup