Solid
storagedrive.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright 2006-2007 Kevin Ottens <ervin@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Lesser General Public 00006 License as published by the Free Software Foundation; either 00007 version 2.1 of the License, or (at your option) version 3, or any 00008 later version accepted by the membership of KDE e.V. (or its 00009 successor approved by the membership of KDE e.V.), which shall 00010 act as a proxy defined in Section 6 of version 3 of the license. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #include "storagedrive.h" 00022 #include "storagedrive_p.h" 00023 00024 #include "soliddefs_p.h" 00025 #include <solid/ifaces/storagedrive.h> 00026 #include "predicate.h" 00027 #include "storageaccess.h" 00028 #include "device.h" 00029 #include "device_p.h" 00030 00031 Solid::StorageDrive::StorageDrive(QObject *backendObject) 00032 : DeviceInterface(*new StorageDrivePrivate(), backendObject) 00033 { 00034 } 00035 00036 Solid::StorageDrive::StorageDrive(StorageDrivePrivate &dd, QObject *backendObject) 00037 : DeviceInterface(dd, backendObject) 00038 { 00039 00040 } 00041 00042 Solid::StorageDrive::~StorageDrive() 00043 { 00044 00045 } 00046 00047 Solid::StorageDrive::Bus Solid::StorageDrive::bus() const 00048 { 00049 Q_D(const StorageDrive); 00050 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), Platform, bus()); 00051 } 00052 00053 Solid::StorageDrive::DriveType Solid::StorageDrive::driveType() const 00054 { 00055 Q_D(const StorageDrive); 00056 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), HardDisk, driveType()); 00057 } 00058 00059 bool Solid::StorageDrive::isRemovable() const 00060 { 00061 Q_D(const StorageDrive); 00062 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isRemovable()); 00063 } 00064 00065 bool Solid::StorageDrive::isHotpluggable() const 00066 { 00067 Q_D(const StorageDrive); 00068 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, isHotpluggable()); 00069 } 00070 00071 qulonglong Solid::StorageDrive::size() const 00072 { 00073 Q_D(const StorageDrive); 00074 return_SOLID_CALL(Ifaces::StorageDrive *, d->backendObject(), false, size()); 00075 } 00076 00077 bool Solid::StorageDrive::isInUse() const 00078 { 00079 Q_D(const StorageDrive); 00080 Predicate p(DeviceInterface::StorageAccess); 00081 QList<Device> devices = Device::listFromQuery(p, d->devicePrivate()->udi()); 00082 00083 bool inUse = false; 00084 foreach (const Device &dev, devices) { 00085 if (dev.is<Solid::StorageAccess>()) { 00086 const Solid::StorageAccess* access = dev.as<Solid::StorageAccess>(); 00087 inUse |= (access->isAccessible()); 00088 } 00089 } 00090 return inUse; 00091 } 00092 00093 #include "storagedrive.moc" 00094
KDE 4.6 API Reference