summaryrefslogtreecommitdiff
authorbenmeyer <benmeyer>2002-10-17 15:29:40 (UTC)
committer benmeyer <benmeyer>2002-10-17 15:29:40 (UTC)
commite1005c586b436d8edb7958632c7d71b4f5b00c2f (patch) (unidiff)
treee39830884da8238cc355f96cde39c002eb1d7ed3
parent8a9b63594f8500ffbb5e58a74e98504bcf20fcb9 (diff)
downloadopie-e1005c586b436d8edb7958632c7d71b4f5b00c2f.zip
opie-e1005c586b436d8edb7958632c7d71b4f5b00c2f.tar.gz
opie-e1005c586b436d8edb7958632c7d71b4f5b00c2f.tar.bz2
usb now supported
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(){
231 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
232 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
233 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
234 */ 234 */
235void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
236 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
237 if(!item){ 237 if(!item){
238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
239 return; 239 return;
240 } 240 }
241 241
242 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return;
246 }
243 if(i->getModuleOwner()){ 247 if(i->getModuleOwner()){
244 QTabWidget *tabWidget = NULL; 248 QTabWidget *tabWidget = NULL;
245 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
246 if(moduleInformation != NULL){ 250 if(moduleInformation != NULL){
247 if(tabWidget != NULL){ 251 if(tabWidget != NULL){
248 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
249 tabWidget->insertTab(information, "TCP/IP"); 253 tabWidget->insertTab(information, "TCP/IP");
250 } 254 }
251 moduleInformation->showMaximized(); 255 moduleInformation->showMaximized();
252 moduleInformation->show(); 256 moduleInformation->show();
253 return; 257 return;
254 } 258 }
@@ -260,57 +264,54 @@ void MainWindowImp::informationClicked(){
260} 264}
261 265
262/** 266/**
263 * Aquire the list of active interfaces from ifconfig 267 * Aquire the list of active interfaces from ifconfig
264 * Call ifconfig and ifconfig -a 268 * Call ifconfig and ifconfig -a
265 */ 269 */
266void MainWindowImp::getInterfaceList(){ 270void MainWindowImp::getInterfaceList(){
267 KShellProcess *processAll = new KShellProcess(); 271 KShellProcess *processAll = new KShellProcess();
268 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
269 connect(processAll, SIGNAL(processExited(KProcess *)), 273 connect(processAll, SIGNAL(processExited(KProcess *)),
270 this, SLOT(jobDone(KProcess *))); 274 this, SLOT(jobDone(KProcess *)));
271 threads.insert(processAll, TEMP_ALL); 275 threads.insert(processAll, TEMP_ALL);
272 processAll->start(KShellProcess::NotifyOnExit);
273 276
274 KShellProcess *process = new KShellProcess(); 277 KShellProcess *process = new KShellProcess();
275 *process << "/sbin/ifconfig" << " > " TEMP_UP; 278 *process << "/sbin/ifconfig" << " > " TEMP_UP;
276 connect(process, SIGNAL(processExited(KProcess *)), 279 connect(process, SIGNAL(processExited(KProcess *)),
277 this, SLOT(jobDone(KProcess *))); 280 this, SLOT(jobDone(KProcess *)));
278 threads.insert(process, TEMP_UP); 281 threads.insert(process, TEMP_UP);
282
283 processAll->start(KShellProcess::NotifyOnExit);
279 process->start(KShellProcess::NotifyOnExit); 284 process->start(KShellProcess::NotifyOnExit);
280} 285}
281 286
282void MainWindowImp::jobDone(KProcess *process){ 287void MainWindowImp::jobDone(KProcess *process){
283 QString fileName = threads[process]; 288 QString fileName = threads[process];
284 threads.remove(process); 289 threads.remove(process);
285 delete process; 290 delete process;
286 291
287 QFile file(fileName); 292 QFile file(fileName);
288 if (!file.open(IO_ReadOnly)){ 293 if (!file.open(IO_ReadOnly)){
289 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
290 return; 295 return;
291 } 296 }
292 297
293 QTextStream stream( &file ); 298 QTextStream stream( &file );
294 QString line; 299 QString line;
295 while ( !stream.eof() ) { 300 while ( !stream.eof() ) {
296 line = stream.readLine(); 301 line = stream.readLine();
297 int space = line.find(" "); 302 int space = line.find(" ");
298 if(space > 1){ 303 if(space > 1){
299 // We have found an interface 304 // We have found an interface
300 QString interfaceName = line.mid(0, space); 305 QString interfaceName = line.mid(0, space);
301 if(!advancedUserMode){
302 if(interfaceName == "lo")
303 break;
304 }
305 Interface *i; 306 Interface *i;
306 // See if we already have it 307 // See if we already have it
307 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
308 if(fileName == TEMP_ALL) 309 if(fileName == TEMP_ALL)
309 i = new Interface(interfaceName, false); 310 i = new Interface(interfaceName, false);
310 else 311 else
311 i = new Interface(interfaceName, true); 312 i = new Interface(interfaceName, true);
312 } 313 }
313 else{ 314 else{
314 i = interfaceNames[interfaceName]; 315 i = interfaceNames[interfaceName];
315 if(fileName != TEMP_ALL) 316 if(fileName != TEMP_ALL)
316 i->setStatus(true); 317 i->setStatus(true);
@@ -325,48 +326,57 @@ void MainWindowImp::jobDone(KProcess *process){
325 if(macAddress == -1) 326 if(macAddress == -1)
326 macAddress = line.length(); 327 macAddress = line.length();
327 if(hardwareName != -1) 328 if(hardwareName != -1)
328 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
329 // We have found an interface 330 // We have found an interface
330 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
331 interfaceNames.insert(i->getInterfaceName(), i); 332 interfaceNames.insert(i->getInterfaceName(), i);
332 updateInterface(i); 333 updateInterface(i);
333 } 334 }
334 } 335 }
335 file.close(); 336 file.close();
336 QFile::remove(fileName); 337 QFile::remove(fileName);
338
337 if(threads.count() == 0){ 339 if(threads.count() == 0){
338 Interfaces i; 340 Interfaces i;
339 QStringList list = i.getInterfaceList(); 341 QStringList list = i.getInterfaceList();
340 QMap<QString, Interface*>::Iterator it; 342 QMap<QString, Interface*>::Iterator it;
341 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 343 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
344 bool found = false;
342 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 345 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
343 if(it.key() == (*ni)){ 346 if(it.key() == (*ni))
344 Interface *i = new Interface(*ni, false); 347 found = true;
345 i->setAttached(false); 348 }
346 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 349 if(!found){
347 i->setInterfaceName(*ni); 350 Interface *i = new Interface(*ni, false);
348 interfaceNames.insert(i->getInterfaceName(), i); 351 i->setAttached(false);
349 updateInterface(i); 352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
350 } 353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i);
351 } 356 }
352 } 357 }
353 } 358 }
354} 359}
355 360
356/** 361/**
357 * Update this interface. If no QListViewItem exists create one. 362 * Update this interface. If no QListViewItem exists create one.
358 * @param Interface* pointer to the interface that needs to be updated. 363 * @param Interface* pointer to the interface that needs to be updated.
359 */ 364 */
360void MainWindowImp::updateInterface(Interface *i){ 365void MainWindowImp::updateInterface(Interface *i){
366 if(!advancedUserMode){
367 if(i->getInterfaceName() == "lo")
368 return;
369 }
370
361 QListViewItem *item = NULL; 371 QListViewItem *item = NULL;
362 372
363 // Find the interface, making it if needed. 373 // Find the interface, making it if needed.
364 if(items.find(i) == items.end()){ 374 if(items.find(i) == items.end()){
365 item = new QListViewItem(connectionList, "", "", ""); 375 item = new QListViewItem(connectionList, "", "", "");
366 // See if you can't find a module owner for this interface 376 // See if you can't find a module owner for this interface
367 QMap<Module*, QLibrary*>::Iterator it; 377 QMap<Module*, QLibrary*>::Iterator it;
368 for( it = libraries.begin(); it != libraries.end(); ++it ){ 378 for( it = libraries.begin(); it != libraries.end(); ++it ){
369 if(it.key()->isOwner(i)) 379 if(it.key()->isOwner(i))
370 i->setModuleOwner(it.key()); 380 i->setModuleOwner(it.key());
371 } 381 }
372 items.insert(i, item); 382 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(){
231 * Report an error if no interface is selected. 231 * Report an error if no interface is selected.
232 * If the interface has a module owner then request its configure with a empty 232 * If the interface has a module owner then request its configure with a empty
233 * tab. If tab is !NULL then append the interfaces setup widget to it. 233 * tab. If tab is !NULL then append the interfaces setup widget to it.
234 */ 234 */
235void MainWindowImp::informationClicked(){ 235void MainWindowImp::informationClicked(){
236 QListViewItem *item = connectionList->currentItem(); 236 QListViewItem *item = connectionList->currentItem();
237 if(!item){ 237 if(!item){
238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); 238 QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok);
239 return; 239 return;
240 } 240 }
241 241
242 Interface *i = interfaceItems[item]; 242 Interface *i = interfaceItems[item];
243 if(!i->isAttached()){
244 QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok);
245 return;
246 }
243 if(i->getModuleOwner()){ 247 if(i->getModuleOwner()){
244 QTabWidget *tabWidget = NULL; 248 QTabWidget *tabWidget = NULL;
245 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget); 249 QWidget *moduleInformation = i->getModuleOwner()->information(&tabWidget);
246 if(moduleInformation != NULL){ 250 if(moduleInformation != NULL){
247 if(tabWidget != NULL){ 251 if(tabWidget != NULL){
248 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); 252 InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true);
249 tabWidget->insertTab(information, "TCP/IP"); 253 tabWidget->insertTab(information, "TCP/IP");
250 } 254 }
251 moduleInformation->showMaximized(); 255 moduleInformation->showMaximized();
252 moduleInformation->show(); 256 moduleInformation->show();
253 return; 257 return;
254 } 258 }
@@ -260,57 +264,54 @@ void MainWindowImp::informationClicked(){
260} 264}
261 265
262/** 266/**
263 * Aquire the list of active interfaces from ifconfig 267 * Aquire the list of active interfaces from ifconfig
264 * Call ifconfig and ifconfig -a 268 * Call ifconfig and ifconfig -a
265 */ 269 */
266void MainWindowImp::getInterfaceList(){ 270void MainWindowImp::getInterfaceList(){
267 KShellProcess *processAll = new KShellProcess(); 271 KShellProcess *processAll = new KShellProcess();
268 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; 272 *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL;
269 connect(processAll, SIGNAL(processExited(KProcess *)), 273 connect(processAll, SIGNAL(processExited(KProcess *)),
270 this, SLOT(jobDone(KProcess *))); 274 this, SLOT(jobDone(KProcess *)));
271 threads.insert(processAll, TEMP_ALL); 275 threads.insert(processAll, TEMP_ALL);
272 processAll->start(KShellProcess::NotifyOnExit);
273 276
274 KShellProcess *process = new KShellProcess(); 277 KShellProcess *process = new KShellProcess();
275 *process << "/sbin/ifconfig" << " > " TEMP_UP; 278 *process << "/sbin/ifconfig" << " > " TEMP_UP;
276 connect(process, SIGNAL(processExited(KProcess *)), 279 connect(process, SIGNAL(processExited(KProcess *)),
277 this, SLOT(jobDone(KProcess *))); 280 this, SLOT(jobDone(KProcess *)));
278 threads.insert(process, TEMP_UP); 281 threads.insert(process, TEMP_UP);
282
283 processAll->start(KShellProcess::NotifyOnExit);
279 process->start(KShellProcess::NotifyOnExit); 284 process->start(KShellProcess::NotifyOnExit);
280} 285}
281 286
282void MainWindowImp::jobDone(KProcess *process){ 287void MainWindowImp::jobDone(KProcess *process){
283 QString fileName = threads[process]; 288 QString fileName = threads[process];
284 threads.remove(process); 289 threads.remove(process);
285 delete process; 290 delete process;
286 291
287 QFile file(fileName); 292 QFile file(fileName);
288 if (!file.open(IO_ReadOnly)){ 293 if (!file.open(IO_ReadOnly)){
289 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); 294 qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1());
290 return; 295 return;
291 } 296 }
292 297
293 QTextStream stream( &file ); 298 QTextStream stream( &file );
294 QString line; 299 QString line;
295 while ( !stream.eof() ) { 300 while ( !stream.eof() ) {
296 line = stream.readLine(); 301 line = stream.readLine();
297 int space = line.find(" "); 302 int space = line.find(" ");
298 if(space > 1){ 303 if(space > 1){
299 // We have found an interface 304 // We have found an interface
300 QString interfaceName = line.mid(0, space); 305 QString interfaceName = line.mid(0, space);
301 if(!advancedUserMode){
302 if(interfaceName == "lo")
303 break;
304 }
305 Interface *i; 306 Interface *i;
306 // See if we already have it 307 // See if we already have it
307 if(interfaceNames.find(interfaceName) == interfaceNames.end()){ 308 if(interfaceNames.find(interfaceName) == interfaceNames.end()){
308 if(fileName == TEMP_ALL) 309 if(fileName == TEMP_ALL)
309 i = new Interface(interfaceName, false); 310 i = new Interface(interfaceName, false);
310 else 311 else
311 i = new Interface(interfaceName, true); 312 i = new Interface(interfaceName, true);
312 } 313 }
313 else{ 314 else{
314 i = interfaceNames[interfaceName]; 315 i = interfaceNames[interfaceName];
315 if(fileName != TEMP_ALL) 316 if(fileName != TEMP_ALL)
316 i->setStatus(true); 317 i->setStatus(true);
@@ -325,48 +326,57 @@ void MainWindowImp::jobDone(KProcess *process){
325 if(macAddress == -1) 326 if(macAddress == -1)
326 macAddress = line.length(); 327 macAddress = line.length();
327 if(hardwareName != -1) 328 if(hardwareName != -1)
328 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); 329 i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
329 // We have found an interface 330 // We have found an interface
330 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); 331 //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
331 interfaceNames.insert(i->getInterfaceName(), i); 332 interfaceNames.insert(i->getInterfaceName(), i);
332 updateInterface(i); 333 updateInterface(i);
333 } 334 }
334 } 335 }
335 file.close(); 336 file.close();
336 QFile::remove(fileName); 337 QFile::remove(fileName);
338
337 if(threads.count() == 0){ 339 if(threads.count() == 0){
338 Interfaces i; 340 Interfaces i;
339 QStringList list = i.getInterfaceList(); 341 QStringList list = i.getInterfaceList();
340 QMap<QString, Interface*>::Iterator it; 342 QMap<QString, Interface*>::Iterator it;
341 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 343 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
344 bool found = false;
342 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 345 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
343 if(it.key() == (*ni)){ 346 if(it.key() == (*ni))
344 Interface *i = new Interface(*ni, false); 347 found = true;
345 i->setAttached(false); 348 }
346 i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); 349 if(!found){
347 i->setInterfaceName(*ni); 350 Interface *i = new Interface(*ni, false);
348 interfaceNames.insert(i->getInterfaceName(), i); 351 i->setAttached(false);
349 updateInterface(i); 352 i->setHardwareName(QString("Disconnected (%1)").arg(*ni));
350 } 353 i->setInterfaceName(*ni);
354 interfaceNames.insert(i->getInterfaceName(), i);
355 updateInterface(i);
351 } 356 }
352 } 357 }
353 } 358 }
354} 359}
355 360
356/** 361/**
357 * Update this interface. If no QListViewItem exists create one. 362 * Update this interface. If no QListViewItem exists create one.
358 * @param Interface* pointer to the interface that needs to be updated. 363 * @param Interface* pointer to the interface that needs to be updated.
359 */ 364 */
360void MainWindowImp::updateInterface(Interface *i){ 365void MainWindowImp::updateInterface(Interface *i){
366 if(!advancedUserMode){
367 if(i->getInterfaceName() == "lo")
368 return;
369 }
370
361 QListViewItem *item = NULL; 371 QListViewItem *item = NULL;
362 372
363 // Find the interface, making it if needed. 373 // Find the interface, making it if needed.
364 if(items.find(i) == items.end()){ 374 if(items.find(i) == items.end()){
365 item = new QListViewItem(connectionList, "", "", ""); 375 item = new QListViewItem(connectionList, "", "", "");
366 // See if you can't find a module owner for this interface 376 // See if you can't find a module owner for this interface
367 QMap<Module*, QLibrary*>::Iterator it; 377 QMap<Module*, QLibrary*>::Iterator it;
368 for( it = libraries.begin(); it != libraries.end(); ++it ){ 378 for( it = libraries.begin(); it != libraries.end(); ++it ){
369 if(it.key()->isOwner(i)) 379 if(it.key()->isOwner(i))
370 i->setModuleOwner(it.key()); 380 i->setModuleOwner(it.key());
371 } 381 }
372 items.insert(i, item); 382 items.insert(i, item);