author | benmeyer <benmeyer> | 2002-10-17 16:30:44 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-17 16:30:44 (UTC) |
commit | 18cc7321db186865629a5c4702074211e42b92fd (patch) (unidiff) | |
tree | beb15112009c1cc966115904a322b32d465e47e6 /noncore/settings/networksettings/mainwindowimp.cpp | |
parent | 75f078ec92376db2c90a327bbc50d9bb5c1fb57a (diff) | |
download | opie-18cc7321db186865629a5c4702074211e42b92fd.zip opie-18cc7321db186865629a5c4702074211e42b92fd.tar.gz opie-18cc7321db186865629a5c4702074211e42b92fd.tar.bz2 |
interface is now a qobject
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index b46362f..117bac1 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -295,73 +295,74 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
295 | return; | 295 | return; |
296 | } | 296 | } |
297 | 297 | ||
298 | QTextStream stream( &file ); | 298 | QTextStream stream( &file ); |
299 | QString line; | 299 | QString line; |
300 | while ( !stream.eof() ) { | 300 | while ( !stream.eof() ) { |
301 | line = stream.readLine(); | 301 | line = stream.readLine(); |
302 | int space = line.find(" "); | 302 | int space = line.find(" "); |
303 | if(space > 1){ | 303 | if(space > 1){ |
304 | // We have found an interface | 304 | // We have found an interface |
305 | QString interfaceName = line.mid(0, space); | 305 | QString interfaceName = line.mid(0, space); |
306 | Interface *i; | 306 | Interface *i; |
307 | // We have found an interface | ||
308 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | ||
307 | // See if we already have it | 309 | // See if we already have it |
308 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 310 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
309 | if(fileName == TEMP_ALL) | 311 | if(fileName == TEMP_ALL) |
310 | i = new Interface(interfaceName, false); | 312 | i = new Interface(this, interfaceName, false); |
311 | else | 313 | else |
312 | i = new Interface(interfaceName, true); | 314 | i = new Interface(this, interfaceName, true); |
315 | i->setAttached(true); | ||
316 | |||
317 | QString hardName = "Ethernet"; | ||
318 | int hardwareName = line.find("Link encap:"); | ||
319 | int macAddress = line.find("HWaddr"); | ||
320 | if(macAddress == -1) | ||
321 | macAddress = line.length(); | ||
322 | if(hardwareName != -1) | ||
323 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); | ||
324 | |||
325 | interfaceNames.insert(i->getInterfaceName(), i); | ||
326 | updateInterface(i); | ||
327 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | ||
313 | } | 328 | } |
329 | // It was an interface we already had. | ||
314 | else{ | 330 | else{ |
315 | i = interfaceNames[interfaceName]; | 331 | i = interfaceNames[interfaceName]; |
316 | if(fileName != TEMP_ALL) | 332 | if(fileName != TEMP_ALL) |
317 | i->setStatus(true); | 333 | i->setStatus(true); |
318 | } | 334 | } |
319 | |||
320 | i->setAttached(true); | ||
321 | i->setInterfaceName(interfaceName); | ||
322 | |||
323 | QString hardName = "Ethernet"; | ||
324 | int hardwareName = line.find("Link encap:"); | ||
325 | int macAddress = line.find("HWaddr"); | ||
326 | if(macAddress == -1) | ||
327 | macAddress = line.length(); | ||
328 | if(hardwareName != -1) | ||
329 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName())); | ||
330 | // We have found an interface | ||
331 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | ||
332 | interfaceNames.insert(i->getInterfaceName(), i); | ||
333 | updateInterface(i); | ||
334 | } | 335 | } |
335 | } | 336 | } |
336 | file.close(); | 337 | file.close(); |
337 | QFile::remove(fileName); | 338 | QFile::remove(fileName); |
338 | 339 | ||
339 | if(threads.count() == 0){ | 340 | if(threads.count() == 0){ |
340 | Interfaces i; | 341 | Interfaces i; |
341 | QStringList list = i.getInterfaceList(); | 342 | QStringList list = i.getInterfaceList(); |
342 | QMap<QString, Interface*>::Iterator it; | 343 | QMap<QString, Interface*>::Iterator it; |
343 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 344 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
344 | bool found = false; | 345 | bool found = false; |
345 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 346 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
346 | if(it.key() == (*ni)) | 347 | if(it.key() == (*ni)) |
347 | found = true; | 348 | found = true; |
348 | } | 349 | } |
349 | if(!found){ | 350 | if(!found){ |
350 | Interface *i = new Interface(*ni, false); | 351 | Interface *i = new Interface(this, *ni, false); |
351 | i->setAttached(false); | 352 | i->setAttached(false); |
352 | i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); | 353 | i->setHardwareName(QString("Disconnected (%1)").arg(*ni)); |
353 | i->setInterfaceName(*ni); | ||
354 | interfaceNames.insert(i->getInterfaceName(), i); | 354 | interfaceNames.insert(i->getInterfaceName(), i); |
355 | updateInterface(i); | 355 | updateInterface(i); |
356 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | ||
356 | } | 357 | } |
357 | } | 358 | } |
358 | } | 359 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | /** | 362 | /** |
362 | * Update this interface. If no QListViewItem exists create one. | 363 | * Update this interface. If no QListViewItem exists create one. |
363 | * @param Interface* pointer to the interface that needs to be updated. | 364 | * @param Interface* pointer to the interface that needs to be updated. |
364 | */ | 365 | */ |
365 | void MainWindowImp::updateInterface(Interface *i){ | 366 | void MainWindowImp::updateInterface(Interface *i){ |
366 | if(!advancedUserMode){ | 367 | if(!advancedUserMode){ |
367 | if(i->getInterfaceName() == "lo") | 368 | if(i->getInterfaceName() == "lo") |
@@ -386,25 +387,27 @@ void MainWindowImp::updateInterface(Interface *i){ | |||
386 | item = items[i]; | 387 | item = items[i]; |
387 | 388 | ||
388 | // Update the icons and information | 389 | // Update the icons and information |
389 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 390 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
390 | 391 | ||
391 | QString typeName = "lan"; | 392 | QString typeName = "lan"; |
392 | if(i->getHardwareName().contains("Local Loopback")) | 393 | if(i->getHardwareName().contains("Local Loopback")) |
393 | typeName = "lo"; | 394 | typeName = "lo"; |
394 | if(i->getInterfaceName().contains("irda")) | 395 | if(i->getInterfaceName().contains("irda")) |
395 | typeName = "irda"; | 396 | typeName = "irda"; |
396 | if(i->getInterfaceName().contains("wlan")) | 397 | if(i->getInterfaceName().contains("wlan")) |
397 | typeName = "wlan"; | 398 | typeName = "wlan"; |
398 | 399 | if(i->getInterfaceName().contains("usb")) | |
400 | typeName = "usb"; | ||
401 | |||
399 | if(!i->isAttached()) | 402 | if(!i->isAttached()) |
400 | typeName = "connect_no"; | 403 | typeName = "connect_no"; |
401 | // Actually try to use the Module | 404 | // Actually try to use the Module |
402 | if(i->getModuleOwner() != NULL) | 405 | if(i->getModuleOwner() != NULL) |
403 | typeName = i->getModuleOwner()->getPixmapName(i); | 406 | typeName = i->getModuleOwner()->getPixmapName(i); |
404 | 407 | ||
405 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 408 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
406 | item->setText(2, i->getHardwareName()); | 409 | item->setText(2, i->getHardwareName()); |
407 | item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); | 410 | item->setText(3, (i->getStatus()) ? i->getIp() : QString("")); |
408 | } | 411 | } |
409 | 412 | ||
410 | void MainWindowImp::newProfileChanged(const QString& newText){ | 413 | void MainWindowImp::newProfileChanged(const QString& newText){ |