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 
FakeStorage(FakeDevice * device)12 FakeStorage::FakeStorage(FakeDevice *device)
13     : FakeBlock(device)
14 {
15 }
16 
~FakeStorage()17 FakeStorage::~FakeStorage()
18 {
19 }
20 
bus() const21 Solid::StorageDrive::Bus FakeStorage::bus() const
22 {
23     QString bus = fakeDevice()->property("bus").toString();
24 
25     if (bus == "ide") {
26         return Solid::StorageDrive::Ide;
27     } else if (bus == "usb") {
28         return Solid::StorageDrive::Usb;
29     } else if (bus == "ieee1394") {
30         return Solid::StorageDrive::Ieee1394;
31     } else if (bus == "scsi") {
32         return Solid::StorageDrive::Scsi;
33     } else if (bus == "sata") {
34         return Solid::StorageDrive::Sata;
35     } else {
36         return Solid::StorageDrive::Platform;
37     }
38 }
39 
driveType() const40 Solid::StorageDrive::DriveType FakeStorage::driveType() const
41 {
42     QString type = fakeDevice()->property("major").toString();
43 
44     if (type == "disk") {
45         return Solid::StorageDrive::HardDisk;
46     } else if (type == "cdrom") {
47         return Solid::StorageDrive::CdromDrive;
48     } else if (type == "floppy") {
49         return Solid::StorageDrive::Floppy;
50     } else if (type == "tape") {
51         return Solid::StorageDrive::Tape;
52     } else if (type == "compact_flash") {
53         return Solid::StorageDrive::CompactFlash;
54     } else if (type == "memory_stick") {
55         return Solid::StorageDrive::MemoryStick;
56     } else if (type == "smart_media") {
57         return Solid::StorageDrive::SmartMedia;
58     } else if (type == "sd_mmc") {
59         return Solid::StorageDrive::SdMmc;
60     } else {
61         return Solid::StorageDrive::HardDisk;
62     }
63 }
64 
isRemovable() const65 bool FakeStorage::isRemovable() const
66 {
67     return fakeDevice()->property("isRemovable").toBool();
68 }
69 
isHotpluggable() const70 bool FakeStorage::isHotpluggable() const
71 {
72     return fakeDevice()->property("isHotpluggable").toBool();
73 }
74 
size() const75 qulonglong FakeStorage::size() const
76 {
77     return fakeDevice()->property("size").toULongLong();
78 }
79