| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: 2006 Davide Bettio <davide.bettio@kdemail.net> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #include "fakestorage.h" |
| 8 | #include <QVariant> |
| 9 | |
| 10 | using namespace Solid::Backends::Fake; |
| 11 | |
| 12 | FakeStorage::FakeStorage(FakeDevice *device) |
| 13 | : FakeBlock(device) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | FakeStorage::~FakeStorage() |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | Solid::StorageDrive::Bus FakeStorage::bus() const |
| 22 | { |
| 23 | QString bus = fakeDevice()->property(QStringLiteral("bus")).toString(); |
| 24 | |
| 25 | if (bus == QLatin1String("ide")) { |
| 26 | return Solid::StorageDrive::Ide; |
| 27 | } else if (bus == QLatin1String("usb")) { |
| 28 | return Solid::StorageDrive::Usb; |
| 29 | } else if (bus == QLatin1String("ieee1394")) { |
| 30 | return Solid::StorageDrive::Ieee1394; |
| 31 | } else if (bus == QLatin1String("scsi")) { |
| 32 | return Solid::StorageDrive::Scsi; |
| 33 | } else if (bus == QLatin1String("sata")) { |
| 34 | return Solid::StorageDrive::Sata; |
| 35 | } else { |
| 36 | return Solid::StorageDrive::Platform; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | Solid::StorageDrive::DriveType FakeStorage::driveType() const |
| 41 | { |
| 42 | QString type = fakeDevice()->property(QStringLiteral("major")).toString(); |
| 43 | |
| 44 | if (type == QLatin1String("disk")) { |
| 45 | return Solid::StorageDrive::HardDisk; |
| 46 | } else if (type == QLatin1String("cdrom")) { |
| 47 | return Solid::StorageDrive::CdromDrive; |
| 48 | } else if (type == QLatin1String("floppy")) { |
| 49 | return Solid::StorageDrive::Floppy; |
| 50 | } else if (type == QLatin1String("tape")) { |
| 51 | return Solid::StorageDrive::Tape; |
| 52 | } else if (type == QLatin1String("compact_flash")) { |
| 53 | return Solid::StorageDrive::CompactFlash; |
| 54 | } else if (type == QLatin1String("memory_stick")) { |
| 55 | return Solid::StorageDrive::MemoryStick; |
| 56 | } else if (type == QLatin1String("smart_media")) { |
| 57 | return Solid::StorageDrive::SmartMedia; |
| 58 | } else if (type == QLatin1String("sd_mmc")) { |
| 59 | return Solid::StorageDrive::SdMmc; |
| 60 | } else { |
| 61 | return Solid::StorageDrive::HardDisk; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | bool FakeStorage::isRemovable() const |
| 66 | { |
| 67 | return fakeDevice()->property(QStringLiteral("isRemovable")).toBool(); |
| 68 | } |
| 69 | |
| 70 | bool FakeStorage::isHotpluggable() const |
| 71 | { |
| 72 | return fakeDevice()->property(QStringLiteral("isHotpluggable")).toBool(); |
| 73 | } |
| 74 | |
| 75 | qulonglong FakeStorage::size() const |
| 76 | { |
| 77 | return fakeDevice()->property(QStringLiteral("size")).toULongLong(); |
| 78 | } |
| 79 | |
| 80 | QDateTime FakeStorage::timeDetected() const |
| 81 | { |
| 82 | return fakeDevice()->property(QStringLiteral("timeDetected")).toDateTime(); |
| 83 | } |
| 84 | |
| 85 | QDateTime FakeStorage::timeMediaDetected() const |
| 86 | { |
| 87 | return fakeDevice()->property(QStringLiteral("timeMediaDetected")).toDateTime(); |
| 88 | } |
| 89 | |
| 90 | #include "moc_fakestorage.cpp" |
| 91 |
