00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "soliddeviceengine.h"
00020
00021 #include <config-workspace.h>
00022
00023 #include <KDebug>
00024 #include <KLocale>
00025
00026 #include <Plasma/DataContainer>
00027
00028
00029
00030
00031 #ifdef HAVE_SYS_PARAM_H
00032 #include <sys/param.h>
00033 #endif
00034
00035 #ifdef HAVE_SYS_MOUNT_H
00036 #include <sys/mount.h>
00037 #endif
00038
00039 #include <sys/stat.h>
00040 #ifdef HAVE_SYS_STATFS_H
00041 #include <sys/statfs.h>
00042 #endif
00043 #ifdef HAVE_SYS_STATVFS_H
00044 #include <sys/statvfs.h>
00045 #endif
00046
00047 #ifdef HAVE_SYS_VFS_H
00048 #include <sys/vfs.h>
00049 #endif
00050
00051 SolidDeviceEngine::SolidDeviceEngine(QObject* parent, const QVariantList& args)
00052 : Plasma::DataEngine(parent, args),
00053 temperature(0),
00054 notifier(0)
00055 {
00056 Q_UNUSED(args)
00057 signalmanager = new DeviceSignalMapManager(this);
00058
00059 listenForNewDevices();
00060 temperature = new HddTemp(this);
00061 setMinimumPollingInterval(1000);
00062 connect(this, SIGNAL(sourceRemoved(const QString&)),
00063 this, SLOT(sourceRemoved(const QString&)));
00064 }
00065
00066 SolidDeviceEngine::~SolidDeviceEngine()
00067 {
00068 }
00069
00070 void SolidDeviceEngine::listenForNewDevices()
00071 {
00072 if(notifier) {
00073 return;
00074 }
00075
00076 notifier = Solid::DeviceNotifier::instance();
00077 connect(notifier, SIGNAL(deviceAdded(const QString&)),
00078 this, SLOT(deviceAdded(const QString&)));
00079 connect(notifier, SIGNAL(deviceRemoved(const QString&)),
00080 this, SLOT(deviceRemoved(const QString&)));
00081 }
00082
00083 bool SolidDeviceEngine::sourceRequestEvent(const QString &name)
00084 {
00085
00086
00087 Solid::Predicate predicate = Solid::Predicate::fromString(name);
00088 Solid::Device device(name);
00089 if(predicate.isValid() && !predicatemap.contains(name)) {
00090 foreach (const Solid::Device &device, Solid::Device::listFromQuery(predicate)) {
00091 predicatemap[name] << device.udi();
00092 }
00093 setData(name, predicatemap[name]);
00094 return true;
00095 } else if (device.isValid()) {
00096 if (devicemap.contains(name) ) {
00097 return true;
00098 } else {
00099 devicemap[name] = device;
00100 return populateDeviceData(name);
00101 }
00102 }
00103
00104 kDebug() << "Source is not a predicate or a device.";
00105 return false;
00106 }
00107
00108 void SolidDeviceEngine::sourceRemoved(const QString &source)
00109 {
00110 devicemap.remove(source);
00111 predicatemap.remove(source);
00112 }
00113
00114 bool SolidDeviceEngine::populateDeviceData(const QString &name)
00115 {
00116 Solid::Device device = devicemap.value(name);
00117 if (!device.isValid()) {
00118 return false;
00119 }
00120
00121 QStringList devicetypes;
00122 setData(name, I18N_NOOP("Parent UDI"), device.parentUdi());
00123 setData(name, I18N_NOOP("Vendor"), device.vendor());
00124 setData(name, I18N_NOOP("Product"), device.product());
00125 setData(name, I18N_NOOP("Icon"), device.icon());
00126
00127 if (device.is<Solid::Processor>()) {
00128 Solid::Processor *processor = device.as<Solid::Processor>();
00129 if (processor == 0) {
00130 return false;
00131 }
00132
00133 devicetypes << I18N_NOOP("Processor");
00134 setData(name, I18N_NOOP("Number"), processor->number());
00135 setData(name, I18N_NOOP("Max Speed"), processor->maxSpeed());
00136 setData(name, I18N_NOOP("Can Change Frequency"), processor->canChangeFrequency());
00137 }
00138 if (device.is<Solid::Block>()) {
00139 Solid::Block *block = device.as<Solid::Block>();
00140 if (block == 0) {
00141 return false;
00142 }
00143
00144 devicetypes << I18N_NOOP("Block");
00145 setData(name, I18N_NOOP("Major"), block->deviceMajor());
00146 setData(name, I18N_NOOP("Minor"), block->deviceMajor());
00147 setData(name, I18N_NOOP("Device"), block->device());
00148 }
00149 if (device.is<Solid::StorageAccess>()) {
00150 Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
00151 if (storageaccess == 0) return false;
00152
00153 devicetypes << I18N_NOOP("Storage Access");
00154 setData(name, I18N_NOOP("Accessible"), storageaccess->isAccessible());
00155 setData(name, I18N_NOOP("File Path"), storageaccess->filePath());
00156 QVariant freeDiskVar;
00157 qlonglong freeDisk = freeDiskSpace(storageaccess->filePath());
00158 if ( freeDisk != -1 ) {
00159 freeDiskVar.setValue( freeDisk );
00160 }
00161 setData(name, I18N_NOOP("Free Space"), freeDiskVar );
00162
00163 signalmanager->mapDevice(storageaccess, device.udi());
00164 }
00165 if (device.is<Solid::StorageDrive>()) {
00166 Solid::StorageDrive *storagedrive = device.as<Solid::StorageDrive>();
00167 if (storagedrive == 0) {
00168 return false;
00169 }
00170
00171 devicetypes << I18N_NOOP("Storage Drive");
00172
00173 QStringList bus;
00174 bus << I18N_NOOP("Ide") << I18N_NOOP("Usb") << I18N_NOOP("Ieee1394") << I18N_NOOP("Scsi") << I18N_NOOP("Sata") << I18N_NOOP("Platform");
00175 QStringList drivetype;
00176 drivetype << I18N_NOOP("Hard Disk") << I18N_NOOP("Cdrom Drive") << I18N_NOOP("Floppy") << I18N_NOOP("Tape") << I18N_NOOP("Compact Flash") << I18N_NOOP("Memory Stick") << I18N_NOOP("Smart Media") << I18N_NOOP("SdMmc") << I18N_NOOP("Xd");
00177
00178 setData(name, I18N_NOOP("Bus"), bus.at((int)storagedrive->bus()));
00179 setData(name, I18N_NOOP("Drive Type"), drivetype.at((int)storagedrive->driveType()));
00180 setData(name, I18N_NOOP("Removable"), storagedrive->isRemovable());
00181 setData(name, I18N_NOOP("Hotpluggable"), storagedrive->isHotpluggable());
00182
00183 updateHardDiskTemperature(name);
00184 }
00185 if (device.is<Solid::OpticalDrive>()) {
00186 Solid::OpticalDrive *opticaldrive = device.as<Solid::OpticalDrive>();
00187 if (opticaldrive == 0) {
00188 return false;
00189 }
00190
00191 devicetypes << I18N_NOOP("Optical Drive");
00192
00193 QStringList supportedtypes;
00194 Solid::OpticalDrive::MediumTypes mediatypes = opticaldrive->supportedMedia();
00195 if (mediatypes & Solid::OpticalDrive::Cdr) {
00196 supportedtypes << I18N_NOOP("Cdr");
00197 }
00198 if (mediatypes & Solid::OpticalDrive::Cdrw) {
00199 supportedtypes << I18N_NOOP("Cdrw");
00200 }
00201 if (mediatypes & Solid::OpticalDrive::Dvd) {
00202 supportedtypes << I18N_NOOP("Dvd");
00203 }
00204 if (mediatypes & Solid::OpticalDrive::Dvdr) {
00205 supportedtypes << I18N_NOOP("Dvdr");
00206 }
00207 if (mediatypes & Solid::OpticalDrive::Dvdrw) {
00208 supportedtypes << I18N_NOOP("Dvdrw");
00209 }
00210 if (mediatypes & Solid::OpticalDrive::Dvdram) {
00211 supportedtypes << I18N_NOOP("Dvdram");
00212 }
00213 if (mediatypes & Solid::OpticalDrive::Dvdplusr) {
00214 supportedtypes << I18N_NOOP("Dvdplusr");
00215 }
00216 if (mediatypes & Solid::OpticalDrive::Dvdplusrw) {
00217 supportedtypes << I18N_NOOP("Dvdplusrw");
00218 }
00219 if (mediatypes & Solid::OpticalDrive::Dvdplusdl) {
00220 supportedtypes << I18N_NOOP("Dvdplusdl");
00221 }
00222 if (mediatypes & Solid::OpticalDrive::Dvdplusdlrw) {
00223 supportedtypes << I18N_NOOP("Dvdplusdlrw");
00224 }
00225 if (mediatypes & Solid::OpticalDrive::Bd) {
00226 supportedtypes << I18N_NOOP("Bd");
00227 }
00228 if (mediatypes & Solid::OpticalDrive::Bdr) {
00229 supportedtypes << I18N_NOOP("Bdr");
00230 }
00231 if (mediatypes & Solid::OpticalDrive::Bdre) {
00232 supportedtypes << I18N_NOOP("Bdre");
00233 }
00234 if (mediatypes & Solid::OpticalDrive::HdDvd) {
00235 supportedtypes << I18N_NOOP("HdDvd");
00236 }
00237 if (mediatypes & Solid::OpticalDrive::HdDvdr) {
00238 supportedtypes << I18N_NOOP("HdDvdr");
00239 }
00240 if (mediatypes & Solid::OpticalDrive::HdDvdrw) {
00241 supportedtypes << I18N_NOOP("HdDvdrw");
00242 }
00243 setData(name, I18N_NOOP("Supported Media"), supportedtypes);
00244
00245 setData(name, I18N_NOOP("Read Speed"), opticaldrive->readSpeed());
00246 setData(name, I18N_NOOP("Write Speed"), opticaldrive->writeSpeed());
00247
00248
00249 QList<int> writespeeds = opticaldrive->writeSpeeds();
00250 QList<QVariant> variantlist = QList<QVariant>();
00251 foreach(int num, writespeeds) {
00252 variantlist << QVariant(num);
00253 }
00254 setData(name, I18N_NOOP("Write Speeds"), variantlist);
00255
00256 }
00257 if (device.is<Solid::StorageVolume>()) {
00258 Solid::StorageVolume *storagevolume = device.as<Solid::StorageVolume>();
00259 if (storagevolume == 0) {
00260 return false;
00261 }
00262
00263 devicetypes << I18N_NOOP("Storage Volume");
00264
00265 QStringList usagetypes;
00266 usagetypes << i18n("Other") << i18n("Unused") << i18n("File System")
00267 << i18n("Partition Table") << i18n("Raid") << i18n("Encrypted");
00268
00269 if (usagetypes.count() > storagevolume->usage()) {
00270 setData(name, I18N_NOOP("Usage"), usagetypes.at((int)storagevolume->usage()));
00271 } else {
00272 setData(name, I18N_NOOP("Usage"), i18n("Unknown"));
00273 }
00274
00275 setData(name, I18N_NOOP("Ignored"), storagevolume->isIgnored());
00276 setData(name, I18N_NOOP("File System Type"), storagevolume->fsType());
00277 setData(name, I18N_NOOP("Label"), storagevolume->label());
00278 setData(name, I18N_NOOP("Uuid"), storagevolume->uuid());
00279 setData(name, I18N_NOOP("Size"), storagevolume->size());
00280 }
00281 if (device.is<Solid::OpticalDisc>()) {
00282 Solid::OpticalDisc *opticaldisc = device.as<Solid::OpticalDisc>();
00283 if (opticaldisc == 0) {
00284 return false;
00285 }
00286
00287 devicetypes << I18N_NOOP("OpticalDisc");
00288
00289
00290 QStringList contenttypelist;
00291 Solid::OpticalDisc::ContentTypes contenttypes = opticaldisc->availableContent();
00292 if (contenttypes & Solid::OpticalDisc::Audio) {
00293 contenttypelist << I18N_NOOP("Audio");
00294 }
00295 if (contenttypes & Solid::OpticalDisc::Audio) {
00296 contenttypelist << I18N_NOOP("Data");
00297 }
00298 if (contenttypes & Solid::OpticalDisc::Audio) {
00299 contenttypelist << I18N_NOOP("Video Cd");
00300 }
00301 if (contenttypes & Solid::OpticalDisc::Audio) {
00302 contenttypelist << I18N_NOOP("Super Video Cd");
00303 }
00304 if (contenttypes & Solid::OpticalDisc::Audio) {
00305 contenttypelist << I18N_NOOP("Video Dvd");
00306 }
00307 setData(name, I18N_NOOP("Available Content"), contenttypelist);
00308
00309 QStringList disctypes;
00310 disctypes << I18N_NOOP("Unknown Disc Type") << I18N_NOOP("CD Rom") << I18N_NOOP("CD Recordable")
00311 << I18N_NOOP("CD Rewritable") << I18N_NOOP("DVD Rom") << I18N_NOOP("DVD Ram")
00312 << I18N_NOOP("DVD Recordable") << I18N_NOOP("DVD Rewritable") << I18N_NOOP("DVD Plus Recordable")
00313 << I18N_NOOP("DVD Plus Rewritable") << I18N_NOOP("DVD Plus Recordable Duallayer")
00314 << I18N_NOOP("DVD Plus Rewritable Duallayer") << I18N_NOOP("Blu Ray Rom") << I18N_NOOP("Blu Ray Recordable")
00315 << I18N_NOOP("Blu Ray Rewritable") << I18N_NOOP("HD DVD Rom") << I18N_NOOP("HD DVD Recordable")
00316 << I18N_NOOP("HD DVD Rewritable");
00317
00318 setData(name, I18N_NOOP("Disc Type"), disctypes.at((int)opticaldisc->discType() + 1));
00319 setData(name, I18N_NOOP("Appendable"), opticaldisc->isAppendable());
00320 setData(name, I18N_NOOP("Blank"), opticaldisc->isBlank());
00321 setData(name, I18N_NOOP("Rewritable"), opticaldisc->isRewritable());
00322 setData(name, I18N_NOOP("Capacity"), opticaldisc->capacity());
00323 }
00324 if (device.is<Solid::Camera>()) {
00325 Solid::Camera *camera = device.as<Solid::Camera>();
00326 if (camera == 0) {
00327 return false;
00328 }
00329
00330 devicetypes << I18N_NOOP("Camera");
00331
00332 setData(name, I18N_NOOP("Supported Protocols"), camera->supportedProtocols());
00333 setData(name, I18N_NOOP("Supported Drivers"), camera->supportedDrivers());
00334 }
00335 if (device.is<Solid::PortableMediaPlayer>()) {
00336 Solid::PortableMediaPlayer *mediaplayer = device.as<Solid::PortableMediaPlayer>();
00337 if (mediaplayer == 0) {
00338 return false;
00339 }
00340
00341 devicetypes << I18N_NOOP("Portable Media Player");
00342
00343 setData(name, I18N_NOOP("Supported Protocols"), mediaplayer->supportedProtocols());
00344 setData(name, I18N_NOOP("Supported Drivers"), mediaplayer->supportedDrivers());
00345 }
00346 if (device.is<Solid::NetworkInterface>()) {
00347 Solid::NetworkInterface *networkinterface = device.as<Solid::NetworkInterface>();
00348 if (networkinterface == 0) {
00349 return false;
00350 }
00351
00352 devicetypes << I18N_NOOP("Network Interface");
00353
00354 setData(name, I18N_NOOP("Interface Name"), networkinterface->ifaceName());
00355 setData(name, I18N_NOOP("Wireless"), networkinterface->isWireless());
00356 setData(name, I18N_NOOP("Hardware Address"), networkinterface->hwAddress());
00357 setData(name, I18N_NOOP("Mac Address"), networkinterface->macAddress());
00358 }
00359 if (device.is<Solid::AcAdapter>()) {
00360 Solid::AcAdapter *ac = device.as<Solid::AcAdapter>();
00361 if (ac == 0) {
00362 return false;
00363 }
00364
00365 devicetypes << I18N_NOOP("AD Adapter");
00366
00367 setData(name, I18N_NOOP("Plugged In"), ac->isPlugged());
00368 signalmanager->mapDevice(ac, device.udi());
00369 }
00370 if (device.is<Solid::Battery>()) {
00371 Solid::Battery *battery = device.as<Solid::Battery>();
00372 if (battery == 0) {
00373 return false;
00374 }
00375
00376 devicetypes << I18N_NOOP("Battery");
00377
00378 QStringList batterytype;
00379 batterytype << I18N_NOOP("Unknown Battery") << I18N_NOOP("PDA Battery") << I18N_NOOP("UPS Battery")
00380 << I18N_NOOP("Primary Battery") << I18N_NOOP("Mouse Battery") << I18N_NOOP("Keyboard Battery")
00381 << I18N_NOOP("Keyboard Mouse Battery") << I18N_NOOP("Camera Battery");
00382
00383 QStringList chargestate;
00384 chargestate << I18N_NOOP("Fully Charged") << I18N_NOOP("Charging") << I18N_NOOP("Discharging");
00385
00386 setData(name, I18N_NOOP("Plugged In"), battery->isPlugged());
00387 setData(name, I18N_NOOP("Type"), batterytype.at((int)battery->type()));
00388 setData(name, I18N_NOOP("Charge Percent"), battery->chargePercent());
00389 setData(name, I18N_NOOP("Rechargeable"), battery->isRechargeable());
00390 setData(name, I18N_NOOP("Charge State"), chargestate.at((int)battery->chargeState()));
00391
00392 signalmanager->mapDevice(battery, device.udi());
00393 }
00394 if (device.is<Solid::Button>()) {
00395 Solid::Button *button = device.as<Solid::Button>();
00396 if (button == 0) {
00397 return false;
00398 }
00399
00400 devicetypes << I18N_NOOP("Button");
00401
00402 QStringList buttontype;
00403 buttontype << I18N_NOOP("Lid Button") << I18N_NOOP("Power Button") << I18N_NOOP("Sleep Button")
00404 << I18N_NOOP("Unknown Button Type");
00405
00406 setData(name, I18N_NOOP("Type"), buttontype.at((int)button->type()));
00407 setData(name, I18N_NOOP("Has State"), button->hasState());
00408 setData(name, I18N_NOOP("State Value"), button->stateValue());
00409 setData(name, I18N_NOOP("Pressed"), false);
00410
00411 signalmanager->mapDevice(button, device.udi());
00412 }
00413 if (device.is<Solid::AudioInterface>()) {
00414 Solid::AudioInterface *audiointerface = device.as<Solid::AudioInterface>();
00415 if (audiointerface == 0) {
00416 return false;
00417 }
00418
00419 devicetypes << I18N_NOOP("Audio Interface");
00420
00421 QStringList audiodriver;
00422 audiodriver << I18N_NOOP("ALSA") << I18N_NOOP("Open Sound System") << I18N_NOOP("Unknown Audio Driver");
00423
00424 setData(name, I18N_NOOP("Driver"), audiodriver.at((int)audiointerface->driver()));
00425 setData(name, I18N_NOOP("Driver Handle"), audiointerface->driverHandle());
00426 setData(name, I18N_NOOP("Name"), audiointerface->name());
00427
00428
00429 QStringList audiointerfacetypes;
00430 Solid::AudioInterface::AudioInterfaceTypes devicetypes = audiointerface->deviceType();
00431 if (devicetypes & Solid::AudioInterface::UnknownAudioInterfaceType) {
00432 audiointerfacetypes << I18N_NOOP("Unknown Audio Interface Type");
00433 }
00434 if (devicetypes & Solid::AudioInterface::AudioControl) {
00435 audiointerfacetypes << I18N_NOOP("Audio Control");
00436 }
00437 if (devicetypes & Solid::AudioInterface::AudioInput) {
00438 audiointerfacetypes << I18N_NOOP("Audio Input");
00439 }
00440 if (devicetypes & Solid::AudioInterface::AudioOutput) {
00441 audiointerfacetypes << I18N_NOOP("Audio Output");
00442 }
00443 setData(name, I18N_NOOP("Audio Device Type"), audiointerfacetypes);
00444
00445
00446 QStringList soundcardtype;
00447 soundcardtype << I18N_NOOP("Internal Soundcard") << I18N_NOOP("USB Soundcard") << I18N_NOOP("Firewire Soundcard")
00448 << I18N_NOOP("Headset") << I18N_NOOP("Modem");
00449 setData(name, I18N_NOOP("Soundcard Type"), soundcardtype.at((int)audiointerface->soundcardType()));
00450 }
00451 if (device.is<Solid::DvbInterface>()) {
00452 Solid::DvbInterface *dvbinterface = device.as<Solid::DvbInterface>();
00453 if (dvbinterface == 0) {
00454 return false;
00455 }
00456
00457 devicetypes << I18N_NOOP("DVB Interface");
00458
00459 setData(name, I18N_NOOP("Device"), dvbinterface->device());
00460 setData(name, I18N_NOOP("Device Adapter"), dvbinterface->deviceAdapter());
00461
00462
00463 QStringList dvbdevicetypes;
00464 dvbdevicetypes << I18N_NOOP("DVB Unknown") << I18N_NOOP("DVB Audio") << I18N_NOOP("DVB Ca")
00465 << I18N_NOOP("DVB Demux") << I18N_NOOP("DVB DVR") << I18N_NOOP("DVB Frontend")
00466 << I18N_NOOP("DVB Net") << I18N_NOOP("DVB OSD") << I18N_NOOP("DVB Sec") << I18N_NOOP("DVB Video");
00467
00468 setData(name, I18N_NOOP("DVB Device Type"), dvbdevicetypes.at((int)dvbinterface->deviceType()));
00469 setData(name, I18N_NOOP("Device Index"), dvbinterface->deviceIndex());
00470 }
00471 if (device.is<Solid::Video>()) {
00472 Solid::Video *video = device.as<Solid::Video>();
00473 if (video == 0) {
00474 return false;
00475 }
00476
00477 devicetypes << I18N_NOOP("Video");
00478
00479 setData(name, I18N_NOOP("Supported Protocols"), video->supportedProtocols());
00480 setData(name, I18N_NOOP("Supported Drivers"), video->supportedDrivers());
00481
00482 QStringList handles;
00483 foreach (const QString &driver, video->supportedDrivers()) {
00484 handles << video->driverHandle(driver).toString();
00485 }
00486 setData(name, I18N_NOOP("Driver Handles"), handles);
00487 }
00488
00489 setData(name, I18N_NOOP("Device Types"), devicetypes);
00490 return true;
00491 }
00492
00493 void SolidDeviceEngine::deviceAdded(const QString& udi)
00494 {
00495 Solid::Device device(udi);
00496
00497 foreach (const QString &query, predicatemap.keys()) {
00498 Solid::Predicate predicate = Solid::Predicate::fromString(query);
00499 if (predicate.matches(device)) {
00500 predicatemap[query] << udi;
00501 setData(query, predicatemap[query]);
00502 }
00503 }
00504
00505 scheduleSourcesUpdated();
00506 }
00507
00508 qlonglong SolidDeviceEngine::freeDiskSpace(const QString &mountPoint)
00509 {
00510
00511 const QByteArray pathBa=mountPoint.toAscii();
00512
00513 const char *path=pathBa.constData();
00514
00515 #ifdef HAVE_STATVFS
00516 struct statvfs fs_obj;
00517 if (statvfs(path,&fs_obj) < 0) {
00518 return -1;
00519 } else {
00520 return (qlonglong)fs_obj.f_bfree*(qlonglong)fs_obj.f_frsize;
00521 }
00522 #elif defined(HAVE_STATFS) && !defined(USE_SOLARIS)
00523 struct statfs fs_obj;
00524 if (statfs(path,&fs_obj) < 0){
00525 return -1;
00526 }
00527 else{
00528 return (qlonglong)fs_obj.f_bfree*(qlonglong)fs_obj.f_bsize;
00529 }
00530 #else
00531 #ifdef __GNUC__
00532 #warning "This system does not support statfs or statvfs - freeDiskSpace() will return -1"
00533 #endif
00534 #endif
00535 return -1;
00536 }
00537
00538 bool SolidDeviceEngine::updateFreeSpace(const QString &udi)
00539 {
00540 Solid::Device device = devicemap.value(udi);
00541 if (!device.is<Solid::StorageAccess>()) {
00542 return false;
00543 }
00544
00545 Solid::StorageAccess *storageaccess = device.as<Solid::StorageAccess>();
00546 if (storageaccess == 0) return false;
00547
00548 QVariant freeSpaceVar;
00549 qlonglong freeSpace = freeDiskSpace(storageaccess->filePath());
00550 if ( freeSpace != -1 ) {
00551 freeSpaceVar.setValue( freeSpace );
00552 }
00553 setData(udi, I18N_NOOP("Free Space"), freeSpaceVar );
00554 return true;
00555 }
00556
00557 bool SolidDeviceEngine::updateHardDiskTemperature(const QString &udi)
00558 {
00559 Solid::Device device = devicemap.value(udi);
00560 Solid::Block *block = device.as<Solid::Block>();
00561 if (block != 0 && temperature->sources().contains(block->device())) {
00562 setData(udi, I18N_NOOP("Temperature"), temperature->data(block->device(), HddTemp::Temperature));
00563 setData(udi, I18N_NOOP("Temperature Unit"), temperature->data(block->device(), HddTemp::Unit));
00564 return true;
00565 }
00566 return false;
00567 }
00568
00569 bool SolidDeviceEngine::updateSourceEvent(const QString& source)
00570 {
00571 bool update1 = updateFreeSpace(source);
00572 bool update2 = updateHardDiskTemperature(source);
00573
00574 return (update1 || update2);
00575 }
00576
00577 void SolidDeviceEngine::deviceRemoved(const QString& udi)
00578 {
00579 foreach (const QString &query, predicatemap.keys()) {
00580 predicatemap[query].removeAll(udi);
00581 setData(query, predicatemap[query]);
00582 }
00583
00584 devicemap.remove(udi);
00585 removeSource(udi);
00586 scheduleSourcesUpdated();
00587 }
00588
00589 void SolidDeviceEngine::deviceChanged(const QString& udi, const QString &property, const QVariant &value)
00590 {
00591 setData(udi, property, value);
00592 scheduleSourcesUpdated();
00593 }
00594
00595 #include "soliddeviceengine.moc"