File: halvolume.cpp

package info (click to toggle)
cantata 3.4.0.ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,428 kB
  • sloc: cpp: 109,584; perl: 1,366; xml: 722; python: 139; lex: 110; sh: 105; yacc: 78; makefile: 8
file content (116 lines) | stat: -rw-r--r-- 3,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
    Copyright 2006 Kevin Ottens <ervin@kde.org>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) version 3, or any
    later version accepted by the membership of KDE e.V. (or its
    successor approved by the membership of KDE e.V.), which shall
    act as a proxy defined in Section 6 of version 3 of the license.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#include "halvolume.h"
#include "../../genericinterface.h"
#include "halstorageaccess.h"

using namespace Solid::Backends::Hal;

Volume::Volume(HalDevice* device)
	: Block(device)
{
}

Volume::~Volume()
{
}

bool Volume::isIgnored() const
{
	static HalDevice lock("/org/freedesktop/Hal/devices/computer");
	bool isLocked = lock.prop("info.named_locks.Global.org.freedesktop.Hal.Device.Storage.locked").toBool();

	if (m_device->prop("volume.ignore").toBool() || isLocked) {
		return true;
	}

	const QString mount_point = StorageAccess(m_device).filePath();
	const bool mounted = m_device->prop("volume.is_mounted").toBool();
	if (!mounted) {
		return false;
	}
	else if (mount_point.startsWith(QLatin1String("/media/")) || mount_point.startsWith(QLatin1String("/mnt/"))) {
		return false;
	}

	/* Now be a bit more aggressive on what we want to ignore,
     * the user generally need to check only what's removable or in /media
     * the volumes mounted to make the system (/, /boot, /var, etc.)
     * are useless to him.
     */
	Solid::Device drive(m_device->prop("block.storage_device").toString());

	const bool removable = drive.as<Solid::GenericInterface>()->property("storage.removable").toBool();
	const bool hotpluggable = drive.as<Solid::GenericInterface>()->property("storage.hotpluggable").toBool();

	return !removable && !hotpluggable;
}

Solid::StorageVolume::UsageType Volume::usage() const
{
	QString usage = m_device->prop("volume.fsusage").toString();

	if (usage == "filesystem") {
		return Solid::StorageVolume::FileSystem;
	}
	else if (usage == "partitiontable") {
		return Solid::StorageVolume::PartitionTable;
	}
	else if (usage == "raid") {
		return Solid::StorageVolume::Raid;
	}
	else if (usage == "crypto") {
		return Solid::StorageVolume::Encrypted;
	}
	else if (usage == "unused") {
		return Solid::StorageVolume::Unused;
	}
	else {
		return Solid::StorageVolume::Other;
	}
}

QString Volume::fsType() const
{
	return m_device->prop("volume.fstype").toString();
}

QString Volume::label() const
{
	return m_device->prop("volume.label").toString();
}

QString Volume::uuid() const
{
	return m_device->prop("volume.uuid").toString();
}

qulonglong Volume::size() const
{
	return m_device->prop("volume.size").toULongLong();
}

QString Solid::Backends::Hal::Volume::encryptedContainerUdi() const
{
	return m_device->prop("volume.crypto_luks.clear.backing_volume").toString();
}

#include "backends/hal/moc_halvolume.cpp"