summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp36
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp36
2 files changed, 46 insertions, 26 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 24af1ec..b46362f 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -231,24 +231,28 @@ void MainWindowImp::configureClicked(){
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure with a empty
* tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
+ if(!i->isAttached()){
+ QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
+ return;
+ }
if(i->getModuleOwner()){
QTabWidget *tabWidget = NULL;
QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
if(moduleInformation != NULL){
if(tabWidget != NULL){
InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
tabWidget->insertTab(information, "TCP/IP");
}
moduleInformation->showMaximized();
moduleInformation->show();
return;
}
@@ -260,57 +264,54 @@ void MainWindowImp::informationClicked(){
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
*/
void MainWindowImp::getInterfaceList(){
KShellProcess *processAll = new KShellProcess();
*processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
connect(processAll, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(processAll, TEMP_ALL);
- processAll->start(KShellProcess::NotifyOnExit);
KShellProcess *process = new KShellProcess();
*process << "/sbin/ifconfig" << " > " TEMP_UP;
connect(process, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(process, TEMP_UP);
+
+ processAll->start(KShellProcess::NotifyOnExit);
process->start(KShellProcess::NotifyOnExit);
}
void MainWindowImp::jobDone(KProcess *process){
QString fileName = threads[process];
threads.remove(process);
delete process;
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
return;
}
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
QString interfaceName = line.mid(0, space);
- if(!advancedUserMode){
- if(interfaceName == "lo")
- break;
- }
Interface *i;
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(interfaceName, false);
else
i = new Interface(interfaceName, true);
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
i->setStatus(true);
@@ -325,48 +326,57 @@ void MainWindowImp::jobDone(KProcess *process){
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
file.close();
QFile::remove(fileName);
+
if(threads.count() == 0){
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
+ bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
- if(it.key() == (*ni)){
- Interface *i = new Interface(*ni, false);
- i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
- i->setInterfaceName(*ni);
- interfaceNames.insert(i->getInterfaceName(), i);
- updateInterface(i);
- }
+ if(it.key() == (*ni))
+ found = true;
+ }
+ if(!found){
+ Interface *i = new Interface(*ni, false);
+ i->setAttached(false);
+ i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setInterfaceName(*ni);
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
}
}
}
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i){
+ if(!advancedUserMode){
+ if(i->getInterfaceName() == "lo")
+ return;
+ }
+
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()->isOwner(i))
i->setModuleOwner(it.key());
}
items.insert(i, item);
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 24af1ec..b46362f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -231,24 +231,28 @@ void MainWindowImp::configureClicked(){
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure with a empty
* tab. If tab is !NULL then append the interfaces setup widget to it.
*/
void MainWindowImp::informationClicked(){
QListViewItem *item = connectionList->currentItem();
if(!item){
QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
+ if(!i->isAttached()){
+ QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
+ return;
+ }
if(i->getModuleOwner()){
QTabWidget *tabWidget = NULL;
QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
if(moduleInformation != NULL){
if(tabWidget != NULL){
InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
tabWidget->insertTab(information, "TCP/IP");
}
moduleInformation->showMaximized();
moduleInformation->show();
return;
}
@@ -260,57 +264,54 @@ void MainWindowImp::informationClicked(){
}
/**
* Aquire the list of active interfaces from ifconfig
* Call ifconfig and ifconfig -a
*/
void MainWindowImp::getInterfaceList(){
KShellProcess *processAll = new KShellProcess();
*processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
connect(processAll, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(processAll, TEMP_ALL);
- processAll->start(KShellProcess::NotifyOnExit);
KShellProcess *process = new KShellProcess();
*process << "/sbin/ifconfig" << " > " TEMP_UP;
connect(process, SIGNAL(processExited(KProcess *)),
this, SLOT(jobDone(KProcess *)));
threads.insert(process, TEMP_UP);
+
+ processAll->start(KShellProcess::NotifyOnExit);
process->start(KShellProcess::NotifyOnExit);
}
void MainWindowImp::jobDone(KProcess *process){
QString fileName = threads[process];
threads.remove(process);
delete process;
QFile file(fileName);
if (!file.open(IO_ReadOnly)){
qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
return;
}
QTextStream stream( &file );
QString line;
while ( !stream.eof() ) {
line = stream.readLine();
int space = line.find(" ");
if(space > 1){
// We have found an interface
QString interfaceName = line.mid(0, space);
- if(!advancedUserMode){
- if(interfaceName == "lo")
- break;
- }
Interface *i;
// See if we already have it
if(interfaceNames.find(interfaceName) == interfaceNames.end()){
if(fileName == TEMP_ALL)
i = new Interface(interfaceName, false);
else
i = new Interface(interfaceName, true);
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
i->setStatus(true);
@@ -325,48 +326,57 @@ void MainWindowImp::jobDone(KProcess *process){
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
file.close();
QFile::remove(fileName);
+
if(threads.count() == 0){
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
+ bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
- if(it.key() == (*ni)){
- Interface *i = new Interface(*ni, false);
- i->setAttached(false);
- i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
- i->setInterfaceName(*ni);
- interfaceNames.insert(i->getInterfaceName(), i);
- updateInterface(i);
- }
+ if(it.key() == (*ni))
+ found = true;
+ }
+ if(!found){
+ Interface *i = new Interface(*ni, false);
+ i->setAttached(false);
+ i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
+ i->setInterfaceName(*ni);
+ interfaceNames.insert(i->getInterfaceName(), i);
+ updateInterface(i);
}
}
}
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i){
+ if(!advancedUserMode){
+ if(i->getInterfaceName() == "lo")
+ return;
+ }
+
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end()){
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it ){
if(it.key()->isOwner(i))
i->setModuleOwner(it.key());
}
items.insert(i, item);