Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: kde-base/kdelibs/, kde-base/kdelibs/files/
Date: Wed, 20 Jun 2012 11:44:19
Message-Id: 1340192621.0beb40a3423f2a6237e75992aba020f982a72cef.dilfridge@gentoo
1 commit: 0beb40a3423f2a6237e75992aba020f982a72cef
2 Author: Andreas K. Huettel <andreas.huettel <AT> physik <DOT> uni-r <DOT> de>
3 AuthorDate: Wed Jun 20 11:43:41 2012 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 20 11:43:41 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=0beb40a3
7
8 [kde-base/kdelibs] Properly apply udisks2 patch
9
10 (Portage version: 2.2.0_alpha110/git/Linux x86_64, RepoMan options: --force, unsigned Manifest commit)
11
12 ---
13 .../kdelibs/files/kdelibs-4.8.90-udisks2.patch | 3643 ++++++++++++++++++++
14 .../files/kdelibs-4.8.90-udisks2_post.patch | 113 -
15 .../files/kdelibs-4.8.90-udisks2_prep.patch | 65 -
16 kde-base/kdelibs/kdelibs-4.8.90.ebuild | 5 +-
17 kde-base/kdelibs/kdelibs-9999.ebuild | 5 +-
18 5 files changed, 3645 insertions(+), 186 deletions(-)
19
20 diff --git a/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2.patch b/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2.patch
21 new file mode 100644
22 index 0000000..294ceb8
23 --- /dev/null
24 +++ b/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2.patch
25 @@ -0,0 +1,3643 @@
26 +diff -ruN kdelibs-4.8.90.orig/solid/solid/CMakeLists.txt kdelibs-4.8.90/solid/solid/CMakeLists.txt
27 +--- kdelibs-4.8.90.orig/solid/solid/CMakeLists.txt 2012-05-23 01:45:27.000000000 +0200
28 ++++ kdelibs-4.8.90/solid/solid/CMakeLists.txt 2012-06-20 13:39:51.000000000 +0200
29 +@@ -1,6 +1,7 @@
30 + set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
31 + add_subdirectory( ifaces )
32 + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
33 ++include_directories( ${QT_QTDBUS_INCLUDE_DIR} )
34 +
35 + if(WIN32)
36 + include_directories( ${KDEWIN_INCLUDES} )
37 +@@ -39,7 +40,6 @@
38 +
39 + file(MAKE_DIRECTORY
40 + ${CMAKE_CURRENT_BINARY_DIR}/backends/fakehw
41 +- ${CMAKE_CURRENT_BINARY_DIR}/backends/hal
42 + ${CMAKE_CURRENT_BINARY_DIR}/backends/udev
43 + ${CMAKE_CURRENT_BINARY_DIR}/backends/wmi
44 + )
45 +@@ -225,33 +225,6 @@
46 + endif( UDEV_FOUND )
47 +
48 +
49 +- message(STATUS "Building Solid HAL backend." )
50 +- set(solid_LIB_SRCS ${solid_LIB_SRCS}
51 +- backends/hal/halacadapter.cpp
52 +- backends/hal/halaudiointerface.cpp
53 +- backends/hal/halbattery.cpp
54 +- backends/hal/halblock.cpp
55 +- backends/hal/halbutton.cpp
56 +- backends/hal/halcamera.cpp
57 +- backends/hal/halcdrom.cpp
58 +- backends/hal/haldeviceinterface.cpp
59 +- backends/hal/haldvbinterface.cpp
60 +- backends/hal/halfstabhandling.cpp
61 +- backends/hal/halgenericinterface.cpp
62 +- backends/hal/haldevice.cpp
63 +- backends/hal/halmanager.cpp
64 +- backends/hal/halnetworkinterface.cpp
65 +- backends/hal/halserialinterface.cpp
66 +- backends/hal/halopticaldisc.cpp
67 +- backends/hal/halportablemediaplayer.cpp
68 +- backends/hal/halprocessor.cpp
69 +- backends/hal/halstorageaccess.cpp
70 +- backends/hal/halstorage.cpp
71 +- backends/hal/halvideo.cpp
72 +- backends/hal/halvolume.cpp
73 +- backends/hal/halsmartcardreader.cpp
74 +- )
75 +-
76 + message(STATUS "Building Solid UPower backend." )
77 + set(solid_LIB_SRCS ${solid_LIB_SRCS}
78 + backends/upower/upowermanager.cpp
79 +@@ -264,18 +237,19 @@
80 +
81 + # FIXME: this should work on more Unix systems
82 + if (CMAKE_SYSTEM_NAME MATCHES Linux)
83 +- message(STATUS "Building Solid UDisks backend." )
84 ++ message(STATUS "Building Solid UDisks2 backend." )
85 + set(solid_LIB_SRCS ${solid_LIB_SRCS}
86 +- backends/udisks/udisksmanager.cpp
87 +- backends/udisks/udisksdevice.cpp
88 +- backends/udisks/udisksblock.cpp
89 +- backends/udisks/udisksstoragevolume.cpp
90 +- backends/udisks/udisksdeviceinterface.cpp
91 +- backends/udisks/udisksopticaldisc.cpp
92 +- backends/udisks/udisksopticaldrive.cpp
93 +- backends/udisks/udisksstoragedrive.cpp
94 +- backends/udisks/udisksstorageaccess.cpp
95 +- backends/udisks/udisksgenericinterface.cpp
96 ++ backends/udisks2/udisksmanager.cpp
97 ++ backends/udisks2/udisksdevice.cpp
98 ++ backends/udisks2/udisksblock.cpp
99 ++ backends/udisks2/udisksstoragevolume.cpp
100 ++ backends/udisks2/udisksdeviceinterface.cpp
101 ++ backends/udisks2/udisksopticaldisc.cpp
102 ++ backends/udisks2/udisksopticaldrive.cpp
103 ++ backends/udisks2/udisksstoragedrive.cpp
104 ++ backends/udisks2/udisksstorageaccess.cpp
105 ++ backends/udisks2/udisksgenericinterface.cpp
106 ++ backends/udisks2/dbus/manager.cpp
107 + )
108 + endif (CMAKE_SYSTEM_NAME MATCHES Linux)
109 +
110 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.cpp
111 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.cpp 1970-01-01 01:00:00.000000000 +0100
112 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.cpp 2012-06-20 13:39:24.000000000 +0200
113 +@@ -0,0 +1,26 @@
114 ++/*
115 ++ * This file was generated by qdbusxml2cpp version 0.7
116 ++ * Command line was: qdbusxml2cpp -p manager manager.xml
117 ++ *
118 ++ * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
119 ++ *
120 ++ * This is an auto-generated file.
121 ++ * This file may have been hand-edited. Look for HAND-EDIT comments
122 ++ * before re-generating it.
123 ++ */
124 ++
125 ++#include "manager.h"
126 ++
127 ++/*
128 ++ * Implementation of interface class OrgFreedesktopDBusObjectManagerInterface
129 ++ */
130 ++
131 ++OrgFreedesktopDBusObjectManagerInterface::OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
132 ++ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
133 ++{
134 ++}
135 ++
136 ++OrgFreedesktopDBusObjectManagerInterface::~OrgFreedesktopDBusObjectManagerInterface()
137 ++{
138 ++}
139 ++
140 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.h kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.h
141 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.h 1970-01-01 01:00:00.000000000 +0100
142 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.h 2012-06-20 13:39:24.000000000 +0200
143 +@@ -0,0 +1,59 @@
144 ++/*
145 ++ * This file was generated by qdbusxml2cpp version 0.7
146 ++ * Command line was: qdbusxml2cpp -p manager manager.xml
147 ++ *
148 ++ * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
149 ++ *
150 ++ * This is an auto-generated file.
151 ++ * Do not edit! All changes made to it will be lost.
152 ++ */
153 ++
154 ++#ifndef MANAGER_H_1329493525
155 ++#define MANAGER_H_1329493525
156 ++
157 ++#include <QtCore/QObject>
158 ++#include <QtCore/QByteArray>
159 ++#include <QtCore/QList>
160 ++#include <QtCore/QMap>
161 ++#include <QtCore/QString>
162 ++#include <QtCore/QStringList>
163 ++#include <QtCore/QVariant>
164 ++#include <QtDBus/QtDBus>
165 ++
166 ++#include "../udisks2.h"
167 ++
168 ++/*
169 ++ * Proxy class for interface org.freedesktop.DBus.ObjectManager
170 ++ */
171 ++class OrgFreedesktopDBusObjectManagerInterface: public QDBusAbstractInterface
172 ++{
173 ++ Q_OBJECT
174 ++public:
175 ++ static inline const char *staticInterfaceName()
176 ++ { return "org.freedesktop.DBus.ObjectManager"; }
177 ++
178 ++public:
179 ++ OrgFreedesktopDBusObjectManagerInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
180 ++
181 ++ ~OrgFreedesktopDBusObjectManagerInterface();
182 ++
183 ++public Q_SLOTS: // METHODS
184 ++ inline QDBusPendingReply<DBUSManagerStruct> GetManagedObjects()
185 ++ {
186 ++ QList<QVariant> argumentList;
187 ++ return asyncCallWithArgumentList(QLatin1String("GetManagedObjects"), argumentList);
188 ++ }
189 ++
190 ++Q_SIGNALS: // SIGNALS
191 ++ void InterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties);
192 ++ void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
193 ++};
194 ++
195 ++namespace org {
196 ++ namespace freedesktop {
197 ++ namespace DBus {
198 ++ typedef ::OrgFreedesktopDBusObjectManagerInterface ObjectManager;
199 ++ }
200 ++ }
201 ++}
202 ++#endif
203 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.xml kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.xml
204 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/dbus/manager.xml 1970-01-01 01:00:00.000000000 +0100
205 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/dbus/manager.xml 2012-06-20 13:39:24.000000000 +0200
206 +@@ -0,0 +1,21 @@
207 ++<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
208 ++ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
209 ++<node>
210 ++ <interface name="org.freedesktop.DBus.ObjectManager">
211 ++ <method name="GetManagedObjects">
212 ++ <arg type="a{oa{sa{sv}}}" name="object_paths_interfaces_and_properties" direction="out">
213 ++ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBUSManagerStruct"/>
214 ++ </arg>
215 ++ </method>
216 ++ <signal name="InterfacesAdded">
217 ++ <arg type="o" name="object_path"/>
218 ++ <arg type="a{sa{sv}}" name="interfaces_and_properties">
219 ++ <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="QVariantMapMap"/>
220 ++ </arg>
221 ++ </signal>
222 ++ <signal name="InterfacesRemoved">
223 ++ <arg type="o" name="object_path"/>
224 ++ <arg type="as" name="interfaces"/>
225 ++ </signal>
226 ++ </interface>
227 ++</node>
228 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisks2.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisks2.h
229 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisks2.h 1970-01-01 01:00:00.000000000 +0100
230 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisks2.h 2012-06-20 13:39:24.000000000 +0200
231 +@@ -0,0 +1,77 @@
232 ++/*
233 ++ Copyright 2012 Lukáš Tinkl <ltinkl@××××××.com>
234 ++
235 ++ This library is free software; you can redistribute it and/or
236 ++ modify it under the terms of the GNU Lesser General Public
237 ++ License as published by the Free Software Foundation; either
238 ++ version 2.1 of the License, or (at your option) version 3, or any
239 ++ later version accepted by the membership of KDE e.V. (or its
240 ++ successor approved by the membership of KDE e.V.), which shall
241 ++ act as a proxy defined in Section 6 of version 3 of the license.
242 ++
243 ++ This library is distributed in the hope that it will be useful,
244 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
245 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
246 ++ Lesser General Public License for more details.
247 ++
248 ++ You should have received a copy of the GNU Lesser General Public
249 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
250 ++*/
251 ++
252 ++#ifndef SOLID_BACKENDS_UDISKS2_H
253 ++#define SOLID_BACKENDS_UDISKS2_H
254 ++
255 ++#include <QMetaType>
256 ++#include <QtDBus>
257 ++#include <QVariant>
258 ++#include <QMap>
259 ++#include <QList>
260 ++
261 ++typedef QList<QByteArray> QByteArrayList;
262 ++Q_DECLARE_METATYPE(QByteArrayList)
263 ++
264 ++typedef QMap<QString,QVariantMap> QVariantMapMap;
265 ++Q_DECLARE_METATYPE(QVariantMapMap)
266 ++
267 ++typedef QMap<QDBusObjectPath, QVariantMapMap> DBUSManagerStruct;
268 ++Q_DECLARE_METATYPE(DBUSManagerStruct)
269 ++
270 ++/* UDisks2 */
271 ++#define UD2_DBUS_SERVICE "org.freedesktop.UDisks2"
272 ++#define UD2_DBUS_PATH "/org/freedesktop/UDisks2"
273 ++#define UD2_UDI_DISKS_PREFIX "/org/freedesktop/UDisks2"
274 ++#define UD2_DBUS_PATH_MANAGER "/org/freedesktop/UDisks2/Manager"
275 ++#define UD2_DBUS_PATH_DRIVES "/org/freedesktop/UDisks2/drives/"
276 ++#define UD2_DBUS_PATH_JOBS "/org/freedesktop/UDisks2/jobs/"
277 ++#define DBUS_INTERFACE_PROPS "org.freedesktop.DBus.Properties"
278 ++#define DBUS_INTERFACE_INTROSPECT "org.freedesktop.DBus.Introspectable"
279 ++#define DBUS_INTERFACE_MANAGER "org.freedesktop.DBus.ObjectManager"
280 ++#define UD2_DBUS_INTERFACE_BLOCK "org.freedesktop.UDisks2.Block"
281 ++#define UD2_DBUS_INTERFACE_DRIVE "org.freedesktop.UDisks2.Drive"
282 ++#define UD2_DBUS_INTERFACE_PARTITION "org.freedesktop.UDisks2.Partition"
283 ++#define UD2_DBUS_INTERFACE_PARTITIONTABLE "org.freedesktop.UDisks2.PartitionTable"
284 ++#define UD2_DBUS_INTERFACE_FILESYSTEM "org.freedesktop.UDisks2.Filesystem"
285 ++#define UD2_DBUS_INTERFACE_ENCRYPTED "org.freedesktop.UDisks2.Encrypted"
286 ++#define UD2_DBUS_INTERFACE_SWAP "org.freedesktop.UDisks2.Swapspace"
287 ++
288 ++/* errors */
289 ++#define UD2_ERROR_UNAUTHORIZED "org.freedesktop.PolicyKit.Error.NotAuthorized"
290 ++#define UD2_ERROR_BUSY "org.freedesktop.UDisks2.Error.DeviceBusy"
291 ++#define UD2_ERROR_FAILED "org.freedesktop.UDisks2.Error.Failed"
292 ++#define UD2_ERROR_CANCELED "org.freedesktop.UDisks2.Error.Cancelled"
293 ++#define UD2_ERROR_INVALID_OPTION "org.freedesktop.UDisks2.Error.OptionNotPermitted"
294 ++#define UD2_ERROR_MISSING_DRIVER "org.freedesktop.UDisks2.Error.NotSupported"
295 ++
296 ++#define UD2_ERROR_ALREADY_MOUNTED "org.freedesktop.UDisks2.Error.AlreadyMounted"
297 ++#define UD2_ERROR_NOT_MOUNTED "org.freedesktop.UDisks2.Error.NotMounted"
298 ++#define UD2_ERROR_MOUNTED_BY_OTHER_USER "org.freedesktop.UDisks2.Error.MountedByOtherUser"
299 ++#define UD2_ERROR_ALREADY_UNMOUNTING "org.freedesktop.UDisks2.Error.AlreadyUnmounting"
300 ++#define UD2_ERROR_TIMED_OUT "org.freedesktop.UDisks2.Error.Timedout"
301 ++#define UD2_ERROR_WOULD_WAKEUP "org.freedesktop.UDisks2.Error.WouldWakeup"
302 ++#define UD2_ERROR_ALREADY_CANCELLED "org.freedesktop.UDisks2.Error.AlreadyCancelled"
303 ++
304 ++#define UD2_ERROR_NOT_AUTHORIZED "org.freedesktop.UDisks2.Error.NotAuthorized"
305 ++#define UD2_ERROR_NOT_AUTHORIZED_CAN_OBTAIN "org.freedesktop.UDisks2.Error.NotAuthorizedCanObtain"
306 ++#define UD2_ERROR_NOT_AUTHORIZED_DISMISSED "org.freedesktop.UDisks2.Error.NotAuthorizedDismissed"
307 ++
308 ++#endif // SOLID_BACKENDS_UDISKS2_H
309 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksblock.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksblock.cpp
310 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksblock.cpp 1970-01-01 01:00:00.000000000 +0100
311 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksblock.cpp 2012-06-20 13:39:24.000000000 +0200
312 +@@ -0,0 +1,84 @@
313 ++/*
314 ++ Copyright 2012 Lukáš Tinkl <ltinkl@××××××.com>
315 ++
316 ++ This library is free software; you can redistribute it and/or
317 ++ modify it under the terms of the GNU Lesser General Public
318 ++ License as published by the Free Software Foundation; either
319 ++ version 2.1 of the License, or (at your option) version 3, or any
320 ++ later version accepted by the membership of KDE e.V. (or its
321 ++ successor approved by the membership of KDE e.V.), which shall
322 ++ act as a proxy defined in Section 6 of version 3 of the license.
323 ++
324 ++ This library is distributed in the hope that it will be useful,
325 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
326 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
327 ++ Lesser General Public License for more details.
328 ++
329 ++ You should have received a copy of the GNU Lesser General Public
330 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
331 ++*/
332 ++
333 ++#include <linux/kdev_t.h>
334 ++
335 ++#include <QFile>
336 ++#include <QtDBus/QDBusConnection>
337 ++#include <QtDBus/QDBusPendingReply>
338 ++
339 ++#include "udisksblock.h"
340 ++#include "dbus/manager.h"
341 ++
342 ++using namespace Solid::Backends::UDisks2;
343 ++
344 ++Block::Block(Device *dev)
345 ++ : DeviceInterface(dev)
346 ++{
347 ++ m_devNum = m_device->prop("DeviceNumber").toULongLong();
348 ++ m_devFile = QFile::decodeName(m_device->prop("Device").toByteArray());
349 ++
350 ++ // we have a drive (non-block device for udisks), so let's find the corresponding (real) block device
351 ++ if (m_devNum == 0 || m_devFile.isEmpty()) {
352 ++ org::freedesktop::DBus::ObjectManager manager(UD2_DBUS_SERVICE, UD2_DBUS_PATH, QDBusConnection::systemBus());
353 ++ QDBusPendingReply<DBUSManagerStruct> reply = manager.GetManagedObjects();
354 ++ reply.waitForFinished();
355 ++ if (!reply.isError()) { // enum devices
356 ++ Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) {
357 ++ const QString udi = path.path();
358 ++
359 ++ if (udi == UD2_DBUS_PATH_MANAGER || udi == UD2_UDI_DISKS_PREFIX || udi.startsWith(UD2_DBUS_PATH_JOBS))
360 ++ continue;
361 ++
362 ++ Device device(udi);
363 ++ if (device.drivePath() == dev->udi()) {
364 ++ m_devNum = device.prop("DeviceNumber").toULongLong();
365 ++ m_devFile = QFile::decodeName(device.prop("Device").toByteArray());
366 ++ break;
367 ++ }
368 ++ }
369 ++ }
370 ++ else // show error
371 ++ {
372 ++ qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message();
373 ++ }
374 ++ }
375 ++
376 ++ qDebug() << "devnum:" << m_devNum << "dev file:" << m_devFile;
377 ++}
378 ++
379 ++Block::~Block()
380 ++{
381 ++}
382 ++
383 ++QString Block::device() const
384 ++{
385 ++ return m_devFile;
386 ++}
387 ++
388 ++int Block::deviceMinor() const
389 ++{
390 ++ return MINOR(m_devNum);
391 ++}
392 ++
393 ++int Block::deviceMajor() const
394 ++{
395 ++ return MAJOR(m_devNum);
396 ++}
397 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksblock.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksblock.h
398 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksblock.h 1970-01-01 01:00:00.000000000 +0100
399 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksblock.h 2012-06-20 13:39:24.000000000 +0200
400 +@@ -0,0 +1,56 @@
401 ++/*
402 ++ Copyright 2012 Lukáš Tinkl <ltinkl@××××××.com>
403 ++
404 ++ This library is free software; you can redistribute it and/or
405 ++ modify it under the terms of the GNU Lesser General Public
406 ++ License as published by the Free Software Foundation; either
407 ++ version 2.1 of the License, or (at your option) version 3, or any
408 ++ later version accepted by the membership of KDE e.V. (or its
409 ++ successor approved by the membership of KDE e.V.), which shall
410 ++ act as a proxy defined in Section 6 of version 3 of the license.
411 ++
412 ++ This library is distributed in the hope that it will be useful,
413 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
414 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
415 ++ Lesser General Public License for more details.
416 ++
417 ++ You should have received a copy of the GNU Lesser General Public
418 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
419 ++*/
420 ++
421 ++#ifndef UDISKS2BLOCK_H
422 ++#define UDISKS2BLOCK_H
423 ++
424 ++#include <solid/ifaces/block.h>
425 ++#include "udisksdeviceinterface.h"
426 ++
427 ++namespace Solid
428 ++{
429 ++namespace Backends
430 ++{
431 ++namespace UDisks2
432 ++{
433 ++
434 ++class Block: public DeviceInterface, virtual public Solid::Ifaces::Block
435 ++{
436 ++
437 ++ Q_OBJECT
438 ++ Q_INTERFACES(Solid::Ifaces::Block)
439 ++
440 ++public:
441 ++ Block(Device *dev);
442 ++ virtual ~Block();
443 ++
444 ++ virtual QString device() const;
445 ++ virtual int deviceMinor() const;
446 ++ virtual int deviceMajor() const;
447 ++private:
448 ++ dev_t m_devNum;
449 ++ QString m_devFile;
450 ++};
451 ++
452 ++}
453 ++}
454 ++}
455 ++
456 ++#endif // UDISKS2BLOCK_H
457 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdevice.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdevice.cpp
458 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdevice.cpp 1970-01-01 01:00:00.000000000 +0100
459 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdevice.cpp 2012-06-20 13:39:24.000000000 +0200
460 +@@ -0,0 +1,910 @@
461 ++/*
462 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
463 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
464 ++
465 ++ This library is free software; you can redistribute it and/or
466 ++ modify it under the terms of the GNU Lesser General Public
467 ++ License as published by the Free Software Foundation; either
468 ++ version 2.1 of the License, or (at your option) version 3, or any
469 ++ later version accepted by the membership of KDE e.V. (or its
470 ++ successor approved by the membership of KDE e.V.), which shall
471 ++ act as a proxy defined in Section 6 of version 3 of the license.
472 ++
473 ++ This library is distributed in the hope that it will be useful,
474 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
475 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
476 ++ Lesser General Public License for more details.
477 ++
478 ++ You should have received a copy of the GNU Lesser General Public
479 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
480 ++*/
481 ++
482 ++#include "udisksdevice.h"
483 ++#include "udisksblock.h"
484 ++#include "udisksdeviceinterface.h"
485 ++#include "udisksstoragevolume.h"
486 ++#include "udisksopticaldisc.h"
487 ++#include "udisksopticaldrive.h"
488 ++#include "udisksstorageaccess.h"
489 ++#include "udisksgenericinterface.h"
490 ++
491 ++#include <solid/genericinterface.h>
492 ++#include <solid/deviceinterface.h>
493 ++#include <solid/device.h>
494 ++
495 ++#include <QtCore/QDebug>
496 ++
497 ++#include <QtDBus/QDBusMessage>
498 ++#include <QtDBus/QDBusMetaType>
499 ++#include <QtDBus/QDBusPendingReply>
500 ++#include <QtDBus/QDBusArgument>
501 ++
502 ++#include <QtXml/QDomDocument>
503 ++
504 ++using namespace Solid::Backends::UDisks2;
505 ++
506 ++// Adapted from KLocale as Solid needs to be Qt-only
507 ++static QString formatByteSize(double size)
508 ++{
509 ++ // Per IEC 60027-2
510 ++
511 ++ // Binary prefixes
512 ++ //Tebi-byte TiB 2^40 1,099,511,627,776 bytes
513 ++ //Gibi-byte GiB 2^30 1,073,741,824 bytes
514 ++ //Mebi-byte MiB 2^20 1,048,576 bytes
515 ++ //Kibi-byte KiB 2^10 1,024 bytes
516 ++
517 ++ QString s;
518 ++ // Gibi-byte
519 ++ if ( size >= 1073741824.0 )
520 ++ {
521 ++ size /= 1073741824.0;
522 ++ if ( size > 1024 ) // Tebi-byte
523 ++ s = QObject::tr("%1 TiB").arg(QLocale().toString(size / 1024.0, 'f', 1));
524 ++ else
525 ++ s = QObject::tr("%1 GiB").arg(QLocale().toString(size, 'f', 1));
526 ++ }
527 ++ // Mebi-byte
528 ++ else if ( size >= 1048576.0 )
529 ++ {
530 ++ size /= 1048576.0;
531 ++ s = QObject::tr("%1 MiB").arg(QLocale().toString(size, 'f', 1));
532 ++ }
533 ++ // Kibi-byte
534 ++ else if ( size >= 1024.0 )
535 ++ {
536 ++ size /= 1024.0;
537 ++ s = QObject::tr("%1 KiB").arg(QLocale().toString(size, 'f', 1));
538 ++ }
539 ++ // Just byte
540 ++ else if ( size > 0 )
541 ++ {
542 ++ s = QObject::tr("%1 B").arg(QLocale().toString(size, 'f', 1));
543 ++ }
544 ++ // Nothing
545 ++ else
546 ++ {
547 ++ s = QObject::tr("0 B");
548 ++ }
549 ++ return s;
550 ++}
551 ++
552 ++Device::Device(const QString &udi)
553 ++ : Solid::Ifaces::Device()
554 ++ , m_udi(udi)
555 ++{
556 ++ m_device = new QDBusInterface(UD2_DBUS_SERVICE, m_udi,
557 ++ QString(), // no interface, we aggregate them
558 ++ QDBusConnection::systemBus());
559 ++
560 ++ if (m_device->isValid()) {
561 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
562 ++ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList)));
563 ++
564 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesAdded",
565 ++ this, SLOT(slotInterfacesAdded(QDBusObjectPath,QVariantMapMap)));
566 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesRemoved",
567 ++ this, SLOT(slotInterfacesRemoved(QDBusObjectPath,QStringList)));
568 ++
569 ++ initInterfaces();
570 ++ }
571 ++}
572 ++
573 ++Device::~Device()
574 ++{
575 ++ delete m_device;
576 ++}
577 ++
578 ++QObject* Device::createDeviceInterface(const Solid::DeviceInterface::Type& type)
579 ++{
580 ++ if (!queryDeviceInterface(type)) {
581 ++ return 0;
582 ++ }
583 ++
584 ++ DeviceInterface *iface = 0;
585 ++ switch (type)
586 ++ {
587 ++ case Solid::DeviceInterface::GenericInterface:
588 ++ iface = new GenericInterface(this);
589 ++ break;
590 ++ case Solid::DeviceInterface::Block:
591 ++ iface = new Block(this);
592 ++ break;
593 ++ case Solid::DeviceInterface::StorageAccess:
594 ++ iface = new StorageAccess(this);
595 ++ break;
596 ++ case Solid::DeviceInterface::StorageDrive:
597 ++ iface = new StorageDrive(this);
598 ++ break;
599 ++ case Solid::DeviceInterface::OpticalDrive:
600 ++ iface = new OpticalDrive(this);
601 ++ break;
602 ++ case Solid::DeviceInterface::StorageVolume:
603 ++ iface = new StorageVolume(this);
604 ++ break;
605 ++ case Solid::DeviceInterface::OpticalDisc:
606 ++ iface = new OpticalDisc(this);
607 ++ break;
608 ++ default:
609 ++ break;
610 ++ }
611 ++ return iface;
612 ++}
613 ++
614 ++bool Device::queryDeviceInterface(const Solid::DeviceInterface::Type& type) const
615 ++{
616 ++ switch (type) {
617 ++ case Solid::DeviceInterface::GenericInterface:
618 ++ return true;
619 ++ case Solid::DeviceInterface::Block:
620 ++ return isBlock();
621 ++ case Solid::DeviceInterface::StorageVolume:
622 ++ return isStorageVolume();
623 ++ case Solid::DeviceInterface::StorageAccess:
624 ++ return isStorageAccess();
625 ++ case Solid::DeviceInterface::StorageDrive:
626 ++ return isDrive();
627 ++ case Solid::DeviceInterface::OpticalDrive:
628 ++ return isOpticalDrive();
629 ++ case Solid::DeviceInterface::OpticalDisc:
630 ++ return isOpticalDisc();
631 ++ default:
632 ++ return false;
633 ++ }
634 ++}
635 ++
636 ++QStringList Device::emblems() const
637 ++{
638 ++ QStringList res;
639 ++
640 ++ if (queryDeviceInterface(Solid::DeviceInterface::StorageAccess))
641 ++ {
642 ++ const UDisks2::StorageAccess accessIface(const_cast<Device *>(this));
643 ++ if (accessIface.isAccessible())
644 ++ {
645 ++ if (isEncryptedContainer())
646 ++ res << "emblem-encrypted-unlocked";
647 ++ else
648 ++ res << "emblem-mounted";
649 ++ }
650 ++ else
651 ++ {
652 ++ if (isEncryptedContainer())
653 ++ res << "emblem-encrypted-locked";
654 ++ else
655 ++ res << "emblem-unmounted";
656 ++ }
657 ++ }
658 ++
659 ++ return res;
660 ++}
661 ++
662 ++QString Device::description() const
663 ++{
664 ++ const QString hintName = prop("HintName").toString();
665 ++ if (!hintName.isEmpty())
666 ++ return hintName;
667 ++
668 ++ if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive))
669 ++ return storageDescription();
670 ++ else if (queryDeviceInterface(Solid::DeviceInterface::StorageVolume))
671 ++ return volumeDescription();
672 ++ else
673 ++ return product();
674 ++}
675 ++
676 ++QString Device::storageDescription() const
677 ++{
678 ++ QString description;
679 ++ const UDisks2::StorageDrive storageDrive(const_cast<Device*>(this));
680 ++ Solid::StorageDrive::DriveType drive_type = storageDrive.driveType();
681 ++ bool drive_is_hotpluggable = storageDrive.isHotpluggable();
682 ++
683 ++ if (drive_type == Solid::StorageDrive::CdromDrive)
684 ++ {
685 ++ const UDisks2::OpticalDrive opticalDrive(const_cast<Device*>(this));
686 ++ Solid::OpticalDrive::MediumTypes mediumTypes = opticalDrive.supportedMedia();
687 ++ QString first;
688 ++ QString second;
689 ++
690 ++ first = QObject::tr("CD-ROM", "First item of %1%2 Drive sentence");
691 ++ if (mediumTypes & Solid::OpticalDrive::Cdr)
692 ++ first = QObject::tr("CD-R", "First item of %1%2 Drive sentence");
693 ++ if (mediumTypes & Solid::OpticalDrive::Cdrw)
694 ++ first = QObject::tr("CD-RW", "First item of %1%2 Drive sentence");
695 ++
696 ++ if (mediumTypes & Solid::OpticalDrive::Dvd)
697 ++ second = QObject::tr("/DVD-ROM", "Second item of %1%2 Drive sentence");
698 ++ if (mediumTypes & Solid::OpticalDrive::Dvdplusr)
699 ++ second = QObject::tr("/DVD+R", "Second item of %1%2 Drive sentence");
700 ++ if (mediumTypes & Solid::OpticalDrive::Dvdplusrw)
701 ++ second = QObject::tr("/DVD+RW", "Second item of %1%2 Drive sentence");
702 ++ if (mediumTypes & Solid::OpticalDrive::Dvdr)
703 ++ second = QObject::tr("/DVD-R", "Second item of %1%2 Drive sentence");
704 ++ if (mediumTypes & Solid::OpticalDrive::Dvdrw)
705 ++ second = QObject::tr("/DVD-RW", "Second item of %1%2 Drive sentence");
706 ++ if (mediumTypes & Solid::OpticalDrive::Dvdram)
707 ++ second = QObject::tr("/DVD-RAM", "Second item of %1%2 Drive sentence");
708 ++ if ((mediumTypes & Solid::OpticalDrive::Dvdr) && (mediumTypes & Solid::OpticalDrive::Dvdplusr))
709 ++ {
710 ++ if(mediumTypes & Solid::OpticalDrive::Dvdplusdl)
711 ++ second = QObject::trUtf8("/DVD±R DL", "Second item of %1%2 Drive sentence");
712 ++ else
713 ++ second = QObject::trUtf8("/DVD±R", "Second item of %1%2 Drive sentence");
714 ++ }
715 ++ if ((mediumTypes & Solid::OpticalDrive::Dvdrw) && (mediumTypes & Solid::OpticalDrive::Dvdplusrw))
716 ++ {
717 ++ if((mediumTypes & Solid::OpticalDrive::Dvdplusdl) || (mediumTypes & Solid::OpticalDrive::Dvdplusdlrw))
718 ++ second = QObject::trUtf8("/DVD±RW DL", "Second item of %1%2 Drive sentence");
719 ++ else
720 ++ second = QObject::trUtf8("/DVD±RW", "Second item of %1%2 Drive sentence");
721 ++ }
722 ++ if (mediumTypes & Solid::OpticalDrive::Bd)
723 ++ second = QObject::tr("/BD-ROM", "Second item of %1%2 Drive sentence");
724 ++ if (mediumTypes & Solid::OpticalDrive::Bdr)
725 ++ second = QObject::tr("/BD-R", "Second item of %1%2 Drive sentence");
726 ++ if (mediumTypes & Solid::OpticalDrive::Bdre)
727 ++ second = QObject::tr("/BD-RE", "Second item of %1%2 Drive sentence");
728 ++ if (mediumTypes & Solid::OpticalDrive::HdDvd)
729 ++ second = QObject::tr("/HD DVD-ROM", "Second item of %1%2 Drive sentence");
730 ++ if (mediumTypes & Solid::OpticalDrive::HdDvdr)
731 ++ second = QObject::tr("/HD DVD-R", "Second item of %1%2 Drive sentence");
732 ++ if (mediumTypes & Solid::OpticalDrive::HdDvdrw)
733 ++ second = QObject::tr("/HD DVD-RW", "Second item of %1%2 Drive sentence");
734 ++
735 ++ if (drive_is_hotpluggable)
736 ++ description = QObject::tr("External %1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second);
737 ++ else
738 ++ description = QObject::tr("%1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second);
739 ++
740 ++ return description;
741 ++ }
742 ++
743 ++ if (drive_type == Solid::StorageDrive::Floppy)
744 ++ {
745 ++ if (drive_is_hotpluggable)
746 ++ description = QObject::tr("External Floppy Drive");
747 ++ else
748 ++ description = QObject::tr("Floppy Drive");
749 ++
750 ++ return description;
751 ++ }
752 ++
753 ++ bool drive_is_removable = storageDrive.isRemovable();
754 ++
755 ++ if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable)
756 ++ {
757 ++ QString size_str = formatByteSize(storageDrive.size());
758 ++ if (!size_str.isEmpty())
759 ++ {
760 ++ if (drive_is_hotpluggable)
761 ++ description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str);
762 ++ else
763 ++ description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str);
764 ++ } else {
765 ++ if (drive_is_hotpluggable)
766 ++ description = QObject::tr("External Hard Drive");
767 ++ else
768 ++ description = QObject::tr("Hard Drive");
769 ++ }
770 ++
771 ++ return description;
772 ++ }
773 ++
774 ++ QString vendormodel_str;
775 ++ QString model = product();
776 ++ QString vendor_str = vendor();
777 ++
778 ++ if (vendor_str.isEmpty())
779 ++ {
780 ++ if (!model.isEmpty())
781 ++ vendormodel_str = model;
782 ++ }
783 ++ else
784 ++ {
785 ++ if (model.isEmpty())
786 ++ vendormodel_str = vendor_str;
787 ++ else
788 ++ {
789 ++ if (model.startsWith(vendor_str))
790 ++ {
791 ++ // e.g. vendor is "Nokia" and model is "Nokia N950" we do not want "Nokia Nokia N950" as description
792 ++ vendormodel_str = model;
793 ++ }
794 ++ else
795 ++ {
796 ++ vendormodel_str = QObject::tr("%1 %2", "%1 is the vendor, %2 is the model of the device").arg(vendor_str).arg(model);
797 ++ }
798 ++ }
799 ++ }
800 ++
801 ++ if (vendormodel_str.isEmpty())
802 ++ description = QObject::tr("Drive");
803 ++ else
804 ++ description = vendormodel_str;
805 ++
806 ++ return description;
807 ++}
808 ++
809 ++QString Device::volumeDescription() const
810 ++{
811 ++ QString description;
812 ++ const UDisks2::StorageVolume storageVolume(const_cast<Device*>(this));
813 ++ QString volume_label = prop("IdLabel").toString();
814 ++ if (volume_label.isEmpty())
815 ++ volume_label = prop("Name").toString();
816 ++ if (!volume_label.isEmpty())
817 ++ return volume_label;
818 ++
819 ++ UDisks2::Device storageDevice(drivePath());
820 ++ const UDisks2::StorageDrive storageDrive(&storageDevice);
821 ++ Solid::StorageDrive::DriveType drive_type = storageDrive.driveType();
822 ++
823 ++ // Handle media in optical drives
824 ++ if (drive_type == Solid::StorageDrive::CdromDrive)
825 ++ {
826 ++ const UDisks2::OpticalDisc disc(const_cast<Device*>(this));
827 ++ switch (disc.discType())
828 ++ {
829 ++ case Solid::OpticalDisc::UnknownDiscType:
830 ++ case Solid::OpticalDisc::CdRom:
831 ++ description = QObject::tr("CD-ROM");
832 ++ break;
833 ++
834 ++ case Solid::OpticalDisc::CdRecordable:
835 ++ if (disc.isBlank())
836 ++ description = QObject::tr("Blank CD-R");
837 ++ else
838 ++ description = QObject::tr("CD-R");
839 ++ break;
840 ++
841 ++ case Solid::OpticalDisc::CdRewritable:
842 ++ if (disc.isBlank())
843 ++ description = QObject::tr("Blank CD-RW");
844 ++ else
845 ++ description = QObject::tr("CD-RW");
846 ++ break;
847 ++
848 ++ case Solid::OpticalDisc::DvdRom:
849 ++ description = QObject::tr("DVD-ROM");
850 ++ break;
851 ++
852 ++ case Solid::OpticalDisc::DvdRam:
853 ++ if (disc.isBlank())
854 ++ description = QObject::tr("Blank DVD-RAM");
855 ++ else
856 ++ description = QObject::tr("DVD-RAM");
857 ++ break;
858 ++
859 ++ case Solid::OpticalDisc::DvdRecordable:
860 ++ if (disc.isBlank())
861 ++ description = QObject::tr("Blank DVD-R");
862 ++ else
863 ++ description = QObject::tr("DVD-R");
864 ++ break;
865 ++
866 ++ case Solid::OpticalDisc::DvdPlusRecordableDuallayer:
867 ++ if (disc.isBlank())
868 ++ description = QObject::tr("Blank DVD+R Dual-Layer");
869 ++ else
870 ++ description = QObject::tr("DVD+R Dual-Layer");
871 ++ break;
872 ++
873 ++ case Solid::OpticalDisc::DvdRewritable:
874 ++ if (disc.isBlank())
875 ++ description = QObject::tr("Blank DVD-RW");
876 ++ else
877 ++ description = QObject::tr("DVD-RW");
878 ++ break;
879 ++
880 ++ case Solid::OpticalDisc::DvdPlusRecordable:
881 ++ if (disc.isBlank())
882 ++ description = QObject::tr("Blank DVD+R");
883 ++ else
884 ++ description = QObject::tr("DVD+R");
885 ++ break;
886 ++
887 ++ case Solid::OpticalDisc::DvdPlusRewritable:
888 ++ if (disc.isBlank())
889 ++ description = QObject::tr("Blank DVD+RW");
890 ++ else
891 ++ description = QObject::tr("DVD+RW");
892 ++ break;
893 ++
894 ++ case Solid::OpticalDisc::DvdPlusRewritableDuallayer:
895 ++ if (disc.isBlank())
896 ++ description = QObject::tr("Blank DVD+RW Dual-Layer");
897 ++ else
898 ++ description = QObject::tr("DVD+RW Dual-Layer");
899 ++ break;
900 ++
901 ++ case Solid::OpticalDisc::BluRayRom:
902 ++ description = QObject::tr("BD-ROM");
903 ++ break;
904 ++
905 ++ case Solid::OpticalDisc::BluRayRecordable:
906 ++ if (disc.isBlank())
907 ++ description = QObject::tr("Blank BD-R");
908 ++ else
909 ++ description = QObject::tr("BD-R");
910 ++ break;
911 ++
912 ++ case Solid::OpticalDisc::BluRayRewritable:
913 ++ if (disc.isBlank())
914 ++ description = QObject::tr("Blank BD-RE");
915 ++ else
916 ++ description = QObject::tr("BD-RE");
917 ++ break;
918 ++
919 ++ case Solid::OpticalDisc::HdDvdRom:
920 ++ description = QObject::tr("HD DVD-ROM");
921 ++ break;
922 ++
923 ++ case Solid::OpticalDisc::HdDvdRecordable:
924 ++ if (disc.isBlank())
925 ++ description = QObject::tr("Blank HD DVD-R");
926 ++ else
927 ++ description = QObject::tr("HD DVD-R");
928 ++ break;
929 ++
930 ++ case Solid::OpticalDisc::HdDvdRewritable:
931 ++ if (disc.isBlank())
932 ++ description = QObject::tr("Blank HD DVD-RW");
933 ++ else
934 ++ description = QObject::tr("HD DVD-RW");
935 ++ break;
936 ++ }
937 ++
938 ++ // Special case for pure audio disc
939 ++ if (disc.availableContent() == Solid::OpticalDisc::Audio)
940 ++ description = QObject::tr("Audio CD");
941 ++
942 ++ return description;
943 ++ }
944 ++
945 ++ const bool drive_is_removable = storageDrive.isRemovable();
946 ++ const bool drive_is_hotpluggable = storageDrive.isHotpluggable();
947 ++
948 ++ QString size_str = formatByteSize(storageVolume.size());
949 ++ if (isEncryptedContainer())
950 ++ {
951 ++ if (!size_str.isEmpty())
952 ++ description = QObject::tr("%1 Encrypted Container", "%1 is the size").arg(size_str);
953 ++ else
954 ++ description = QObject::tr("Encrypted Container");
955 ++ }
956 ++ else if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable)
957 ++ {
958 ++ if (!size_str.isEmpty())
959 ++ {
960 ++ if (drive_is_hotpluggable)
961 ++ description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str);
962 ++ else
963 ++ description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str);
964 ++ }
965 ++ else
966 ++ {
967 ++ if (drive_is_hotpluggable)
968 ++ description = QObject::tr("External Hard Drive");
969 ++ else
970 ++ description = QObject::tr("Hard Drive");
971 ++ }
972 ++ }
973 ++ else
974 ++ {
975 ++ if (drive_is_removable)
976 ++ description = QObject::tr("%1 Removable Media", "%1 is the size").arg(size_str);
977 ++ else
978 ++ description = QObject::tr("%1 Media", "%1 is the size").arg(size_str);
979 ++ }
980 ++
981 ++ return description;
982 ++}
983 ++
984 ++QString Device::icon() const
985 ++{
986 ++ QString iconName = prop( "HintIconName" ).toString();
987 ++
988 ++ if ( !iconName.isEmpty() )
989 ++ {
990 ++ return iconName;
991 ++ }
992 ++ else if (isDrive()) {
993 ++ const bool isRemovable = prop("Removable").toBool();
994 ++ const QString conn = prop("ConnectionBus").toString();
995 ++
996 ++ if (isOpticalDrive())
997 ++ return "drive-optical";
998 ++ else if (isRemovable && !isOpticalDisc()) {
999 ++ if (conn == "usb")
1000 ++ return "drive-removable-media-usb";
1001 ++ else
1002 ++ return "drive-removable-media";
1003 ++ }
1004 ++ }
1005 ++ else if (isBlock()) {
1006 ++ Device drive(drivePath());
1007 ++
1008 ++ // handle media
1009 ++ const QString media = drive.prop("Media").toString();
1010 ++
1011 ++ if ( !media.isEmpty() )
1012 ++ {
1013 ++ if ( isOpticalDisc() ) // optical stuff
1014 ++ {
1015 ++ bool isWritable = drive.prop("OpticalBlank").toBool();
1016 ++
1017 ++ const UDisks2::OpticalDisc disc(const_cast<Device*>(this));
1018 ++ Solid::OpticalDisc::ContentTypes availContent = disc.availableContent();
1019 ++
1020 ++ if (availContent & Solid::OpticalDisc::VideoDvd) // Video DVD
1021 ++ return "media-optical-dvd-video";
1022 ++ else if ((availContent & Solid::OpticalDisc::VideoCd) || (availContent & Solid::OpticalDisc::SuperVideoCd)) // Video CD
1023 ++ return "media-optical-video";
1024 ++ else if ((availContent & Solid::OpticalDisc::Data) && (availContent & Solid::OpticalDisc::Audio)) // Mixed CD
1025 ++ return "media-optical-mixed-cd";
1026 ++ else if (availContent & Solid::OpticalDisc::Audio) // Audio CD
1027 ++ return "media-optical-audio";
1028 ++ else if (availContent & Solid::OpticalDisc::Data) // Data CD
1029 ++ return "media-optical-data";
1030 ++ else if ( isWritable )
1031 ++ return "media-optical-recordable";
1032 ++ else
1033 ++ {
1034 ++ if ( media.startsWith( "optical_dvd" ) || media.startsWith( "optical_hddvd" ) ) // DVD
1035 ++ return "media-optical-dvd";
1036 ++ else if ( media.startsWith( "optical_bd" ) ) // BluRay
1037 ++ return "media-optical-blu-ray";
1038 ++ }
1039 ++
1040 ++ // fallback for every other optical disc
1041 ++ return "media-optical";
1042 ++ }
1043 ++
1044 ++ if ( media == "flash_ms" ) // Flash & Co.
1045 ++ return "media-flash-memory-stick";
1046 ++ else if ( media == "flash_sd" || media == "flash_sdhc" || media == "flash_sdxc" || media == "flash_mmc" )
1047 ++ return "media-flash-sd-mmc";
1048 ++ else if ( media == "flash_sm" )
1049 ++ return "media-flash-smart-media";
1050 ++ else if ( media == "thumb" )
1051 ++ return "drive-removable-media-usb-pendrive";
1052 ++ else if ( media.startsWith( "flash" ) )
1053 ++ return "media-flash";
1054 ++ else if ( media == "floppy" ) // the good ol' floppy
1055 ++ return "media-floppy";
1056 ++ }
1057 ++
1058 ++ if (drive.prop("ConnectionBus").toString() == "sdio") // hack for SD cards connected thru sdio bus
1059 ++ return "media-flash-sd-mmc";
1060 ++
1061 ++ return drive.icon();
1062 ++ }
1063 ++
1064 ++ return "drive-harddisk"; // general fallback
1065 ++}
1066 ++
1067 ++QString Device::product() const
1068 ++{
1069 ++ QString product = prop("Model").toString();
1070 ++
1071 ++ if (!isDrive()) {
1072 ++ QString label = prop("IdLabel").toString();
1073 ++ if (!label.isEmpty()) {
1074 ++ product = label;
1075 ++ }
1076 ++ }
1077 ++
1078 ++ return product;
1079 ++}
1080 ++
1081 ++QString Device::vendor() const
1082 ++{
1083 ++ return prop("Vendor").toString();
1084 ++}
1085 ++
1086 ++QString Device::udi() const
1087 ++{
1088 ++ return m_udi;
1089 ++}
1090 ++
1091 ++QString Device::parentUdi() const
1092 ++{
1093 ++ QString parent;
1094 ++
1095 ++ if (isEncryptedContainer())
1096 ++ parent = prop("CryptoBackingDevice").value<QDBusObjectPath>().path();
1097 ++ else if (propertyExists("Drive")) // block
1098 ++ parent = prop("Drive").value<QDBusObjectPath>().path();
1099 ++ else if (propertyExists("Table")) // partition
1100 ++ parent = prop("Table").value<QDBusObjectPath>().path();
1101 ++ else if (parent.isEmpty() || parent=="/") {
1102 ++ parent = UD2_UDI_DISKS_PREFIX;
1103 ++ }
1104 ++ return parent;
1105 ++}
1106 ++
1107 ++void Device::checkCache(const QString &key) const
1108 ++{
1109 ++ if (m_cache.isEmpty()) // recreate the cache
1110 ++ allProperties();
1111 ++
1112 ++ if (m_cache.contains(key))
1113 ++ return;
1114 ++
1115 ++ QVariant reply = m_device->property(key.toUtf8());
1116 ++
1117 ++ if (reply.isValid()) {
1118 ++ m_cache.insert(key, reply);
1119 ++ } else {
1120 ++ //qDebug() << "got invalid reply for cache:" << key;
1121 ++ //m_cache.insert(key, QVariant());
1122 ++ }
1123 ++}
1124 ++
1125 ++QString Device::introspect() const
1126 ++{
1127 ++ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi,
1128 ++ DBUS_INTERFACE_INTROSPECT, "Introspect");
1129 ++ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
1130 ++ reply.waitForFinished();
1131 ++
1132 ++ if (reply.isValid())
1133 ++ return reply.value();
1134 ++ else {
1135 ++ return QString();
1136 ++ }
1137 ++}
1138 ++
1139 ++QVariant Device::prop(const QString &key) const
1140 ++{
1141 ++ checkCache(key);
1142 ++ return m_cache.value(key);
1143 ++}
1144 ++
1145 ++bool Device::propertyExists(const QString &key) const
1146 ++{
1147 ++ checkCache(key);
1148 ++ return m_cache.contains(key);
1149 ++}
1150 ++
1151 ++QVariantMap Device::allProperties() const
1152 ++{
1153 ++ Q_FOREACH (const QString & iface, m_interfaces) {
1154 ++ if (iface.startsWith("org.freedesktop.DBus"))
1155 ++ continue;
1156 ++ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "GetAll");
1157 ++ call << iface;
1158 ++ QDBusPendingReply<QVariantMap> reply = QDBusConnection::systemBus().asyncCall(call);
1159 ++ reply.waitForFinished();
1160 ++
1161 ++ if (reply.isValid())
1162 ++ m_cache.unite(reply.value());
1163 ++ else
1164 ++ qWarning() << "Error getting props:" << reply.error().name() << reply.error().message();
1165 ++ //qDebug() << "After iface" << iface << ", cache now contains" << m_cache.size() << "items";
1166 ++ }
1167 ++
1168 ++ return m_cache;
1169 ++}
1170 ++
1171 ++bool Device::hasInterface(const QString &name) const
1172 ++{
1173 ++ return m_interfaces.contains(name);
1174 ++}
1175 ++
1176 ++QStringList Device::interfaces() const
1177 ++{
1178 ++ return m_interfaces;
1179 ++}
1180 ++
1181 ++void Device::initInterfaces()
1182 ++{
1183 ++ m_interfaces.clear();
1184 ++ const QString xmlData = introspect();
1185 ++ QDomDocument dom;
1186 ++ dom.setContent(xmlData);
1187 ++ QDomNodeList ifaceNodeList = dom.elementsByTagName("interface");
1188 ++ for (int i = 0; i < ifaceNodeList.count(); i++) {
1189 ++ QDomElement ifaceElem = ifaceNodeList.item(i).toElement();
1190 ++ if (!ifaceElem.isNull())
1191 ++ m_interfaces.append(ifaceElem.attribute("name"));
1192 ++ }
1193 ++ //qDebug() << "Device" << m_udi << "has interfaces:" << m_interfaces;
1194 ++}
1195 ++
1196 ++void Device::slotPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps)
1197 ++{
1198 ++ //Q_UNUSED(ifaceName);
1199 ++
1200 ++ qDebug() << m_udi << "'s interface" << ifaceName << "changed props:";
1201 ++
1202 ++ QMap<QString, int> changeMap;
1203 ++
1204 ++ Q_FOREACH(const QString & key, invalidatedProps) {
1205 ++ m_cache.remove(key);
1206 ++ changeMap.insert(key, Solid::GenericInterface::PropertyRemoved);
1207 ++ qDebug() << "\t invalidated:" << key;
1208 ++ }
1209 ++
1210 ++ QMapIterator<QString, QVariant> i(changedProps);
1211 ++ while (i.hasNext()) {
1212 ++ i.next();
1213 ++ const QString key = i.key();
1214 ++ m_cache.insert(key, i.value()); // replace the value
1215 ++ changeMap.insert(key, Solid::GenericInterface::PropertyModified);
1216 ++ qDebug() << "\t modified:" << key << ":" << m_cache.value(key);
1217 ++ }
1218 ++
1219 ++ Q_EMIT propertyChanged(changeMap);
1220 ++ Q_EMIT changed();
1221 ++}
1222 ++
1223 ++void Device::slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties)
1224 ++{
1225 ++ if (object_path.path() == m_udi) {
1226 ++ m_interfaces.append(interfaces_and_properties.keys());
1227 ++ }
1228 ++}
1229 ++
1230 ++void Device::slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces)
1231 ++{
1232 ++ if (object_path.path() == m_udi) {
1233 ++ Q_FOREACH(const QString & iface, interfaces) {
1234 ++ m_interfaces.removeAll(iface);
1235 ++ }
1236 ++ }
1237 ++}
1238 ++
1239 ++
1240 ++QString Device::errorToString(const QString & error) const
1241 ++{
1242 ++ if (error == UD2_ERROR_UNAUTHORIZED || error == UD2_ERROR_NOT_AUTHORIZED)
1243 ++ return QObject::tr("You are not authorized to perform this operation");
1244 ++ else if (error == UD2_ERROR_BUSY)
1245 ++ return QObject::tr("The device is currently busy");
1246 ++ else if (error == UD2_ERROR_FAILED)
1247 ++ return QObject::tr("The requested operation has failed");
1248 ++ else if (error == UD2_ERROR_CANCELED)
1249 ++ return QObject::tr("The requested operation has been canceled");
1250 ++ else if (error == UD2_ERROR_INVALID_OPTION)
1251 ++ return QObject::tr("An invalid or malformed option has been given");
1252 ++ else if (error == UD2_ERROR_MISSING_DRIVER)
1253 ++ return QObject::tr("The kernel driver for this filesystem type is not available");
1254 ++ else if (error == UD2_ERROR_ALREADY_MOUNTED)
1255 ++ return QObject::tr("The device is already mounted");
1256 ++ else if (error == UD2_ERROR_NOT_MOUNTED)
1257 ++ return QObject::tr("The device is not mounted");
1258 ++ else if (error == UD2_ERROR_MOUNTED_BY_OTHER_USER)
1259 ++ return QObject::tr("The device is mounted by another user");
1260 ++ else if (error == UD2_ERROR_ALREADY_UNMOUNTING)
1261 ++ return QObject::tr("The device is already unmounting");
1262 ++ else if (error == UD2_ERROR_TIMED_OUT)
1263 ++ return QObject::tr("The operation timed out");
1264 ++ else if (error == UD2_ERROR_WOULD_WAKEUP)
1265 ++ return QObject::tr("The operation would wake up a disk that is in a deep-sleep state");
1266 ++ else if (error == UD2_ERROR_ALREADY_CANCELLED)
1267 ++ return QObject::tr("The operation has already been canceled");
1268 ++ else
1269 ++ return QObject::tr("An unspecified error has occurred");
1270 ++}
1271 ++
1272 ++Solid::ErrorType Device::errorToSolidError(const QString & error) const
1273 ++{
1274 ++ if (error == UD2_ERROR_BUSY)
1275 ++ return Solid::DeviceBusy;
1276 ++ else if (error == UD2_ERROR_FAILED)
1277 ++ return Solid::OperationFailed;
1278 ++ else if (error == UD2_ERROR_CANCELED)
1279 ++ return Solid::UserCanceled;
1280 ++ else if (error == UD2_ERROR_INVALID_OPTION)
1281 ++ return Solid::InvalidOption;
1282 ++ else if (error == UD2_ERROR_MISSING_DRIVER)
1283 ++ return Solid::MissingDriver;
1284 ++ else
1285 ++ return Solid::UnauthorizedOperation;
1286 ++}
1287 ++
1288 ++bool Device::isBlock() const
1289 ++{
1290 ++ return hasInterface(UD2_DBUS_INTERFACE_BLOCK);
1291 ++}
1292 ++
1293 ++bool Device::isPartition() const
1294 ++{
1295 ++ return hasInterface(UD2_DBUS_INTERFACE_PARTITION);
1296 ++}
1297 ++
1298 ++bool Device::isPartitionTable() const
1299 ++{
1300 ++ return hasInterface(UD2_DBUS_INTERFACE_PARTITIONTABLE);
1301 ++}
1302 ++
1303 ++bool Device::isStorageVolume() const
1304 ++{
1305 ++ return isPartition() || isPartitionTable() || isStorageAccess() || isOpticalDisc();
1306 ++}
1307 ++
1308 ++bool Device::isStorageAccess() const
1309 ++{
1310 ++ return hasInterface(UD2_DBUS_INTERFACE_FILESYSTEM) || isEncryptedContainer();
1311 ++}
1312 ++
1313 ++bool Device::isDrive() const
1314 ++{
1315 ++ return hasInterface(UD2_DBUS_INTERFACE_DRIVE);
1316 ++}
1317 ++
1318 ++bool Device::isOpticalDrive() const
1319 ++{
1320 ++ return isDrive() && !prop("MediaCompatibility").toStringList().filter("optical_").isEmpty();
1321 ++}
1322 ++
1323 ++bool Device::isOpticalDisc() const
1324 ++{
1325 ++ const QString drv = drivePath();
1326 ++ if (drv.isEmpty() || drv == "/")
1327 ++ return false;
1328 ++
1329 ++ Device drive(drv);
1330 ++ return drive.prop("Optical").toBool();
1331 ++}
1332 ++
1333 ++bool Device::mightBeOpticalDisc() const
1334 ++{
1335 ++ const QString drv = drivePath();
1336 ++ if (drv.isEmpty() || drv == "/")
1337 ++ return false;
1338 ++
1339 ++ Device drive(drv);
1340 ++ return drive.isOpticalDrive();
1341 ++}
1342 ++
1343 ++bool Device::isMounted() const
1344 ++{
1345 ++ return propertyExists("MountPoints") && !qdbus_cast<QByteArrayList>(prop("MountPoints")).isEmpty();
1346 ++}
1347 ++
1348 ++bool Device::isEncryptedContainer() const
1349 ++{
1350 ++ return hasInterface(UD2_DBUS_INTERFACE_ENCRYPTED);
1351 ++}
1352 ++
1353 ++bool Device::isEncryptedCleartext() const
1354 ++{
1355 ++ const QString holderDevice = prop("CryptoBackingDevice").toString();
1356 ++ if (holderDevice.isEmpty() || holderDevice == "/")
1357 ++ return false;
1358 ++ else
1359 ++ return true;
1360 ++}
1361 ++
1362 ++bool Device::isSwap() const
1363 ++{
1364 ++ return hasInterface(UD2_DBUS_INTERFACE_SWAP);
1365 ++}
1366 ++
1367 ++QString Device::drivePath() const
1368 ++{
1369 ++ return prop("Drive").value<QDBusObjectPath>().path();
1370 ++}
1371 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdevice.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdevice.h
1372 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdevice.h 1970-01-01 01:00:00.000000000 +0100
1373 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdevice.h 2012-06-20 13:39:24.000000000 +0200
1374 +@@ -0,0 +1,112 @@
1375 ++/*
1376 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
1377 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
1378 ++
1379 ++ This library is free software; you can redistribute it and/or
1380 ++ modify it under the terms of the GNU Lesser General Public
1381 ++ License as published by the Free Software Foundation; either
1382 ++ version 2.1 of the License, or (at your option) version 3, or any
1383 ++ later version accepted by the membership of KDE e.V. (or its
1384 ++ successor approved by the membership of KDE e.V.), which shall
1385 ++ act as a proxy defined in Section 6 of version 3 of the license.
1386 ++
1387 ++ This library is distributed in the hope that it will be useful,
1388 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1389 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1390 ++ Lesser General Public License for more details.
1391 ++
1392 ++ You should have received a copy of the GNU Lesser General Public
1393 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1394 ++*/
1395 ++
1396 ++#ifndef UDISKS2DEVICE_H
1397 ++#define UDISKS2DEVICE_H
1398 ++
1399 ++#include "udisks2.h"
1400 ++
1401 ++#include <ifaces/device.h>
1402 ++#include <solid/deviceinterface.h>
1403 ++#include <solid/solidnamespace.h>
1404 ++
1405 ++#include <QtDBus/QDBusInterface>
1406 ++#include <QtDBus/QDBusObjectPath>
1407 ++#include <QtCore/QStringList>
1408 ++
1409 ++namespace Solid
1410 ++{
1411 ++namespace Backends
1412 ++{
1413 ++namespace UDisks2
1414 ++{
1415 ++
1416 ++class Device: public Solid::Ifaces::Device
1417 ++{
1418 ++ Q_OBJECT
1419 ++public:
1420 ++ Device(const QString &udi);
1421 ++ virtual ~Device();
1422 ++
1423 ++ virtual QObject* createDeviceInterface(const Solid::DeviceInterface::Type& type);
1424 ++ virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type& type) const;
1425 ++ virtual QString description() const;
1426 ++ virtual QStringList emblems() const;
1427 ++ virtual QString icon() const;
1428 ++ virtual QString product() const;
1429 ++ virtual QString vendor() const;
1430 ++ virtual QString udi() const;
1431 ++ virtual QString parentUdi() const;
1432 ++
1433 ++ QVariant prop(const QString &key) const;
1434 ++ bool propertyExists(const QString &key) const;
1435 ++ QVariantMap allProperties() const;
1436 ++
1437 ++ bool hasInterface(const QString & name) const;
1438 ++ QStringList interfaces() const;
1439 ++
1440 ++ QString errorToString(const QString & error) const;
1441 ++ Solid::ErrorType errorToSolidError(const QString & error) const;
1442 ++
1443 ++ bool isBlock() const;
1444 ++ bool isPartition() const;
1445 ++ bool isPartitionTable() const;
1446 ++ bool isStorageVolume() const;
1447 ++ bool isStorageAccess() const;
1448 ++ bool isDrive() const;
1449 ++ bool isOpticalDrive() const;
1450 ++ bool isOpticalDisc() const;
1451 ++ bool mightBeOpticalDisc() const;
1452 ++ bool isMounted() const;
1453 ++ bool isEncryptedContainer() const;
1454 ++ bool isEncryptedCleartext() const;
1455 ++ bool isSwap() const;
1456 ++
1457 ++ QString drivePath() const;
1458 ++
1459 ++Q_SIGNALS:
1460 ++ void changed();
1461 ++ void propertyChanged(const QMap<QString,int> &changes);
1462 ++
1463 ++private Q_SLOTS:
1464 ++ void slotPropertiesChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps);
1465 ++ void slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties);
1466 ++ void slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
1467 ++
1468 ++private:
1469 ++ QString storageDescription() const;
1470 ++ QString volumeDescription() const;
1471 ++ mutable QDBusInterface *m_device;
1472 ++ QString m_udi;
1473 ++ mutable QVariantMap m_cache;
1474 ++
1475 ++ void initInterfaces();
1476 ++ QStringList m_interfaces;
1477 ++
1478 ++ void checkCache(const QString &key) const;
1479 ++ QString introspect() const;
1480 ++};
1481 ++
1482 ++}
1483 ++}
1484 ++}
1485 ++
1486 ++#endif // UDISKS2DEVICE_H
1487 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdeviceinterface.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdeviceinterface.cpp
1488 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdeviceinterface.cpp 1970-01-01 01:00:00.000000000 +0100
1489 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdeviceinterface.cpp 2012-06-20 13:39:24.000000000 +0200
1490 +@@ -0,0 +1,33 @@
1491 ++/*
1492 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
1493 ++
1494 ++ This library is free software; you can redistribute it and/or
1495 ++ modify it under the terms of the GNU Lesser General Public
1496 ++ License as published by the Free Software Foundation; either
1497 ++ version 2.1 of the License, or (at your option) version 3, or any
1498 ++ later version accepted by the membership of KDE e.V. (or its
1499 ++ successor approved by the membership of KDE e.V.), which shall
1500 ++ act as a proxy defined in Section 6 of version 3 of the license.
1501 ++
1502 ++ This library is distributed in the hope that it will be useful,
1503 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1504 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1505 ++ Lesser General Public License for more details.
1506 ++
1507 ++ You should have received a copy of the GNU Lesser General Public
1508 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1509 ++*/
1510 ++
1511 ++#include "udisksdeviceinterface.h"
1512 ++
1513 ++using namespace Solid::Backends::UDisks2;
1514 ++
1515 ++DeviceInterface::DeviceInterface(Device *device)
1516 ++ : QObject(device), m_device(device)
1517 ++{
1518 ++
1519 ++}
1520 ++
1521 ++DeviceInterface::~DeviceInterface()
1522 ++{
1523 ++}
1524 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdeviceinterface.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdeviceinterface.h
1525 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksdeviceinterface.h 1970-01-01 01:00:00.000000000 +0100
1526 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksdeviceinterface.h 2012-06-20 13:39:24.000000000 +0200
1527 +@@ -0,0 +1,148 @@
1528 ++/*
1529 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
1530 ++
1531 ++ This library is free software; you can redistribute it and/or
1532 ++ modify it under the terms of the GNU Lesser General Public
1533 ++ License as published by the Free Software Foundation; either
1534 ++ version 2.1 of the License, or (at your option) version 3, or any
1535 ++ later version accepted by the membership of KDE e.V. (or its
1536 ++ successor approved by the membership of KDE e.V.), which shall
1537 ++ act as a proxy defined in Section 6 of version 3 of the license.
1538 ++
1539 ++ This library is distributed in the hope that it will be useful,
1540 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1541 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1542 ++ Lesser General Public License for more details.
1543 ++
1544 ++ You should have received a copy of the GNU Lesser General Public
1545 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1546 ++*/
1547 ++
1548 ++#ifndef UDISKS2DEVICEINTERFACE_H
1549 ++#define UDISKS2DEVICEINTERFACE_H
1550 ++
1551 ++#include <ifaces/deviceinterface.h>
1552 ++#include "udisksdevice.h"
1553 ++
1554 ++#include <QtCore/QObject>
1555 ++#include <QtCore/QStringList>
1556 ++
1557 ++namespace Solid
1558 ++{
1559 ++namespace Backends
1560 ++{
1561 ++namespace UDisks2
1562 ++{
1563 ++
1564 ++class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface
1565 ++{
1566 ++ Q_OBJECT
1567 ++ Q_INTERFACES(Solid::Ifaces::DeviceInterface)
1568 ++public:
1569 ++ DeviceInterface(Device *device);
1570 ++ virtual ~DeviceInterface();
1571 ++
1572 ++protected:
1573 ++ Device *m_device;
1574 ++
1575 ++public:
1576 ++ inline static QStringList toStringList(Solid::DeviceInterface::Type type)
1577 ++ {
1578 ++ QStringList list;
1579 ++
1580 ++ switch(type)
1581 ++ {
1582 ++ case Solid::DeviceInterface::GenericInterface:
1583 ++ list << "generic";
1584 ++ break;
1585 ++ case Solid::DeviceInterface::Processor:
1586 ++ // Doesn't exist with UDisks
1587 ++ break;
1588 ++ case Solid::DeviceInterface::Block:
1589 ++ list << "block";
1590 ++ break;
1591 ++ case Solid::DeviceInterface::StorageAccess:
1592 ++ list << "volume";
1593 ++ break;
1594 ++ case Solid::DeviceInterface::StorageDrive:
1595 ++ list << "storage";
1596 ++ break;
1597 ++ case Solid::DeviceInterface::OpticalDrive:
1598 ++ list << "storage.cdrom";
1599 ++ break;
1600 ++ case Solid::DeviceInterface::StorageVolume:
1601 ++ list << "volume";
1602 ++ break;
1603 ++ case Solid::DeviceInterface::OpticalDisc:
1604 ++ list << "volume.disc";
1605 ++ break;
1606 ++ case Solid::DeviceInterface::Camera:
1607 ++ // Doesn't exist with UDisks
1608 ++ break;
1609 ++ case Solid::DeviceInterface::PortableMediaPlayer:
1610 ++ // Doesn't exist with UDisks
1611 ++ break;
1612 ++ case Solid::DeviceInterface::NetworkInterface:
1613 ++ // Doesn't exist with UDisks
1614 ++ break;
1615 ++ case Solid::DeviceInterface::AcAdapter:
1616 ++ // Doesn't exist with UDisks
1617 ++ break;
1618 ++ case Solid::DeviceInterface::Battery:
1619 ++ // Doesn't exist with UDisks
1620 ++ break;
1621 ++ case Solid::DeviceInterface::Button:
1622 ++ // Doesn't exist with UDisks
1623 ++ break;
1624 ++ case Solid::DeviceInterface::AudioInterface:
1625 ++ // Doesn't exist with UDisks
1626 ++ break;
1627 ++ case Solid::DeviceInterface::DvbInterface:
1628 ++ // Doesn't exist with UDisks
1629 ++ break;
1630 ++ case Solid::DeviceInterface::Video:
1631 ++ // Doesn't exist with UDisks
1632 ++ break;
1633 ++ case Solid::DeviceInterface::SerialInterface:
1634 ++ // Doesn't exist with UDisks
1635 ++ break;
1636 ++ case Solid::DeviceInterface::InternetGateway:
1637 ++ break;
1638 ++ case Solid::DeviceInterface::SmartCardReader:
1639 ++ // Doesn't exist with UDisks
1640 ++ case Solid::DeviceInterface::NetworkShare:
1641 ++ // Doesn't exist with UDisks
1642 ++ break;
1643 ++ case Solid::DeviceInterface::Unknown:
1644 ++ break;
1645 ++ case Solid::DeviceInterface::Last:
1646 ++ break;
1647 ++ }
1648 ++
1649 ++ return list;
1650 ++ }
1651 ++
1652 ++ inline static Solid::DeviceInterface::Type fromString(const QString &capability)
1653 ++ {
1654 ++ if (capability == "generic")
1655 ++ return Solid::DeviceInterface::GenericInterface;
1656 ++ else if (capability == "block")
1657 ++ return Solid::DeviceInterface::Block;
1658 ++ else if (capability == "storage")
1659 ++ return Solid::DeviceInterface::StorageDrive;
1660 ++ else if (capability == "storage.cdrom")
1661 ++ return Solid::DeviceInterface::OpticalDrive;
1662 ++ else if (capability == "volume")
1663 ++ return Solid::DeviceInterface::StorageVolume;
1664 ++ else if (capability == "volume.disc")
1665 ++ return Solid::DeviceInterface::OpticalDisc;
1666 ++ else
1667 ++ return Solid::DeviceInterface::Unknown;
1668 ++ }
1669 ++};
1670 ++
1671 ++}
1672 ++}
1673 ++}
1674 ++
1675 ++#endif // UDISKS2DEVICEINTERFACE_H
1676 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksgenericinterface.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksgenericinterface.cpp
1677 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksgenericinterface.cpp 1970-01-01 01:00:00.000000000 +0100
1678 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksgenericinterface.cpp 2012-06-20 13:39:24.000000000 +0200
1679 +@@ -0,0 +1,53 @@
1680 ++/*
1681 ++ Copyright 2009 Pino Toscano <pino@×××.org>
1682 ++ Copyright 2012 Lukáš Tinkl <ltinkl@××××××.com>
1683 ++
1684 ++ This library is free software; you can redistribute it and/or
1685 ++ modify it under the terms of the GNU Lesser General Public
1686 ++ License as published by the Free Software Foundation; either
1687 ++ version 2.1 of the License, or (at your option) version 3, or any
1688 ++ later version accepted by the membership of KDE e.V. (or its
1689 ++ successor approved by the membership of KDE e.V.), which shall
1690 ++ act as a proxy defined in Section 6 of version 3 of the license.
1691 ++
1692 ++ This library is distributed in the hope that it will be useful,
1693 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1694 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1695 ++ Lesser General Public License for more details.
1696 ++
1697 ++ You should have received a copy of the GNU Lesser General Public
1698 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1699 ++*/
1700 ++
1701 ++#include "udisksgenericinterface.h"
1702 ++
1703 ++#include "udisksdevice.h"
1704 ++
1705 ++using namespace Solid::Backends::UDisks2;
1706 ++
1707 ++GenericInterface::GenericInterface(Device *device)
1708 ++ : DeviceInterface(device)
1709 ++{
1710 ++ connect(device, SIGNAL(propertyChanged(QMap<QString,int>)),
1711 ++ this, SIGNAL(propertyChanged(QMap<QString,int>)));
1712 ++}
1713 ++
1714 ++GenericInterface::~GenericInterface()
1715 ++{
1716 ++}
1717 ++
1718 ++QVariant GenericInterface::property(const QString &key) const
1719 ++{
1720 ++ return m_device->prop(key);
1721 ++}
1722 ++
1723 ++QVariantMap GenericInterface::allProperties() const
1724 ++{
1725 ++ return m_device->allProperties();
1726 ++}
1727 ++
1728 ++bool GenericInterface::propertyExists(const QString &key) const
1729 ++{
1730 ++ return m_device->propertyExists(key);
1731 ++}
1732 ++
1733 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksgenericinterface.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksgenericinterface.h
1734 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksgenericinterface.h 1970-01-01 01:00:00.000000000 +0100
1735 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksgenericinterface.h 2012-06-20 13:39:24.000000000 +0200
1736 +@@ -0,0 +1,57 @@
1737 ++/*
1738 ++ Copyright 2009 Pino Toscano <pino@×××.org>
1739 ++
1740 ++ This library is free software; you can redistribute it and/or
1741 ++ modify it under the terms of the GNU Lesser General Public
1742 ++ License as published by the Free Software Foundation; either
1743 ++ version 2.1 of the License, or (at your option) version 3, or any
1744 ++ later version accepted by the membership of KDE e.V. (or its
1745 ++ successor approved by the membership of KDE e.V.), which shall
1746 ++ act as a proxy defined in Section 6 of version 3 of the license.
1747 ++
1748 ++ This library is distributed in the hope that it will be useful,
1749 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1750 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1751 ++ Lesser General Public License for more details.
1752 ++
1753 ++ You should have received a copy of the GNU Lesser General Public
1754 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1755 ++*/
1756 ++
1757 ++#ifndef SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
1758 ++#define SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
1759 ++
1760 ++#include <solid/ifaces/genericinterface.h>
1761 ++#include <solid/genericinterface.h>
1762 ++#include "udisksdeviceinterface.h"
1763 ++
1764 ++namespace Solid
1765 ++{
1766 ++namespace Backends
1767 ++{
1768 ++namespace UDisks2
1769 ++{
1770 ++class Device;
1771 ++
1772 ++class GenericInterface : public DeviceInterface, virtual public Solid::Ifaces::GenericInterface
1773 ++{
1774 ++ Q_OBJECT
1775 ++ Q_INTERFACES(Solid::Ifaces::GenericInterface)
1776 ++
1777 ++public:
1778 ++ GenericInterface(Device *device);
1779 ++ virtual ~GenericInterface();
1780 ++
1781 ++ virtual QVariant property(const QString &key) const;
1782 ++ virtual QVariantMap allProperties() const;
1783 ++ virtual bool propertyExists(const QString &key) const;
1784 ++
1785 ++Q_SIGNALS:
1786 ++ void propertyChanged(const QMap<QString, int> &changes);
1787 ++ void conditionRaised(const QString &condition, const QString &reason);
1788 ++};
1789 ++}
1790 ++}
1791 ++}
1792 ++
1793 ++#endif // SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
1794 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksmanager.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksmanager.cpp
1795 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksmanager.cpp 1970-01-01 01:00:00.000000000 +0100
1796 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksmanager.cpp 2012-06-20 13:39:24.000000000 +0200
1797 +@@ -0,0 +1,227 @@
1798 ++/*
1799 ++ Copyright 2012 Lukáš Tinkl <ltinkl@××××××.com>
1800 ++
1801 ++ This library is free software; you can redistribute it and/or
1802 ++ modify it under the terms of the GNU Lesser General Public
1803 ++ License as published by the Free Software Foundation; either
1804 ++ version 2.1 of the License, or (at your option) version 3, or any
1805 ++ later version accepted by the membership of KDE e.V. (or its
1806 ++ successor approved by the membership of KDE e.V.), which shall
1807 ++ act as a proxy defined in Section 6 of version 3 of the license.
1808 ++
1809 ++ This library is distributed in the hope that it will be useful,
1810 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
1811 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1812 ++ Lesser General Public License for more details.
1813 ++
1814 ++ You should have received a copy of the GNU Lesser General Public
1815 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
1816 ++*/
1817 ++
1818 ++#include "udisksmanager.h"
1819 ++
1820 ++#include <QtCore/QDebug>
1821 ++#include <QtDBus>
1822 ++
1823 ++#include "../shared/rootdevice.h"
1824 ++
1825 ++using namespace Solid::Backends::UDisks2;
1826 ++using namespace Solid::Backends::Shared;
1827 ++
1828 ++Manager::Manager(QObject *parent)
1829 ++ : Solid::Ifaces::DeviceManager(parent),
1830 ++ m_manager(UD2_DBUS_SERVICE,
1831 ++ UD2_DBUS_PATH,
1832 ++ QDBusConnection::systemBus())
1833 ++{
1834 ++ m_supportedInterfaces
1835 ++ << Solid::DeviceInterface::GenericInterface
1836 ++ << Solid::DeviceInterface::Block
1837 ++ << Solid::DeviceInterface::StorageAccess
1838 ++ << Solid::DeviceInterface::StorageDrive
1839 ++ << Solid::DeviceInterface::OpticalDrive
1840 ++ << Solid::DeviceInterface::OpticalDisc
1841 ++ << Solid::DeviceInterface::StorageVolume;
1842 ++
1843 ++ qDBusRegisterMetaType<QList<QDBusObjectPath> >();
1844 ++ qDBusRegisterMetaType<QVariantMap>();
1845 ++ qDBusRegisterMetaType<QVariantMapMap>();
1846 ++ qDBusRegisterMetaType<QByteArrayList>();
1847 ++ qDBusRegisterMetaType<DBUSManagerStruct>();
1848 ++
1849 ++ bool serviceFound = m_manager.isValid();
1850 ++ if (!serviceFound) {
1851 ++ // find out whether it will be activated automatically
1852 ++ QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.DBus",
1853 ++ "/org/freedesktop/DBus",
1854 ++ "org.freedesktop.DBus",
1855 ++ "ListActivatableNames");
1856 ++
1857 ++ QDBusReply<QStringList> reply = QDBusConnection::systemBus().call(message);
1858 ++ if (reply.isValid() && reply.value().contains(UD2_DBUS_SERVICE)) {
1859 ++ QDBusConnection::systemBus().interface()->startService(UD2_DBUS_SERVICE);
1860 ++ serviceFound = true;
1861 ++ }
1862 ++ }
1863 ++
1864 ++ if (serviceFound) {
1865 ++ connect(&m_manager, SIGNAL(InterfacesAdded(QDBusObjectPath, QVariantMapMap)),
1866 ++ this, SLOT(slotInterfacesAdded(QDBusObjectPath,QVariantMapMap)));
1867 ++ connect(&m_manager, SIGNAL(InterfacesRemoved(QDBusObjectPath,QStringList)),
1868 ++ this, SLOT(slotInterfacesRemoved(QDBusObjectPath,QStringList)));
1869 ++ }
1870 ++}
1871 ++
1872 ++Manager::~Manager()
1873 ++{
1874 ++}
1875 ++
1876 ++QObject* Manager::createDevice(const QString& udi)
1877 ++{
1878 ++ if (udi==udiPrefix()) {
1879 ++ RootDevice *root = new RootDevice(udi);
1880 ++
1881 ++ root->setProduct(tr("Storage"));
1882 ++ root->setDescription(tr("Storage devices"));
1883 ++ root->setIcon("server-database"); // Obviously wasn't meant for that, but maps nicely in oxygen icon set :-p
1884 ++
1885 ++ return root;
1886 ++ } else if (deviceCache().contains(udi)) {
1887 ++ return new Device(udi);
1888 ++ } else {
1889 ++ return 0;
1890 ++ }
1891 ++}
1892 ++
1893 ++QStringList Manager::devicesFromQuery(const QString& parentUdi, Solid::DeviceInterface::Type type)
1894 ++{
1895 ++ QStringList result;
1896 ++
1897 ++ if (!parentUdi.isEmpty())
1898 ++ {
1899 ++ Q_FOREACH (const QString &udi, deviceCache())
1900 ++ {
1901 ++ Device device(udi);
1902 ++ if (device.queryDeviceInterface(type) && device.parentUdi() == parentUdi)
1903 ++ result << udi;
1904 ++ }
1905 ++
1906 ++ return result;
1907 ++ }
1908 ++ else if (type != Solid::DeviceInterface::Unknown)
1909 ++ {
1910 ++ Q_FOREACH (const QString &udi, deviceCache())
1911 ++ {
1912 ++ Device device(udi);
1913 ++ if (device.queryDeviceInterface(type))
1914 ++ result << udi;
1915 ++ }
1916 ++
1917 ++ return result;
1918 ++ }
1919 ++
1920 ++ return deviceCache();
1921 ++}
1922 ++
1923 ++QStringList Manager::allDevices()
1924 ++{
1925 ++ m_deviceCache.clear();
1926 ++
1927 ++ QDBusPendingReply<DBUSManagerStruct> reply = m_manager.GetManagedObjects();
1928 ++ reply.waitForFinished();
1929 ++ if (!reply.isError()) { // enum devices
1930 ++ m_deviceCache << udiPrefix();
1931 ++
1932 ++ Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) {
1933 ++ const QString udi = path.path();
1934 ++ qDebug() << "Adding device" << udi;
1935 ++
1936 ++ if (udi == UD2_DBUS_PATH_MANAGER || udi == UD2_UDI_DISKS_PREFIX || udi.startsWith(UD2_DBUS_PATH_JOBS))
1937 ++ continue;
1938 ++
1939 ++ Device device(udi);
1940 ++ if (device.mightBeOpticalDisc()) {
1941 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
1942 ++ SLOT(slotMediaChanged(QDBusMessage)));
1943 ++ if (!device.isOpticalDisc()) // skip empty CD disc
1944 ++ continue;
1945 ++ }
1946 ++
1947 ++ m_deviceCache.append(udi);
1948 ++ }
1949 ++ }
1950 ++ else // show error
1951 ++ {
1952 ++ qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message();
1953 ++ }
1954 ++
1955 ++ return m_deviceCache;
1956 ++}
1957 ++
1958 ++
1959 ++QSet< Solid::DeviceInterface::Type > Manager::supportedInterfaces() const
1960 ++{
1961 ++ return m_supportedInterfaces;
1962 ++}
1963 ++
1964 ++QString Manager::udiPrefix() const
1965 ++{
1966 ++ return UD2_UDI_DISKS_PREFIX;
1967 ++}
1968 ++
1969 ++void Manager::slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties)
1970 ++{
1971 ++ const QString udi = object_path.path();
1972 ++
1973 ++ qDebug() << udi << "has new interfaces:" << interfaces_and_properties.keys();
1974 ++
1975 ++ // new device, we don't know it yet
1976 ++ if (!m_deviceCache.contains(udi)) {
1977 ++ m_deviceCache.append(udi);
1978 ++ Q_EMIT deviceAdded(udi);
1979 ++ }
1980 ++}
1981 ++
1982 ++void Manager::slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces)
1983 ++{
1984 ++ const QString udi = object_path.path();
1985 ++
1986 ++ qDebug() << udi << "lost interfaces:" << interfaces;
1987 ++
1988 ++ Device device(udi);
1989 ++
1990 ++ if (!udi.isEmpty() && (interfaces.isEmpty() || device.interfaces().isEmpty() || device.interfaces().contains(UD2_DBUS_INTERFACE_FILESYSTEM))) {
1991 ++ Q_EMIT deviceRemoved(udi);
1992 ++ m_deviceCache.removeAll(udi);
1993 ++ }
1994 ++}
1995 ++
1996 ++void Manager::slotMediaChanged(const QDBusMessage & msg)
1997 ++{
1998 ++ const QVariantMap properties = qdbus_cast<QVariantMap>(msg.arguments().at(1));
1999 ++
2000 ++ if (!properties.contains("Size")) // react only on Size changes
2001 ++ return;
2002 ++
2003 ++ const QString udi = msg.path();
2004 ++ qulonglong size = properties.value("Size").toULongLong();
2005 ++ qDebug() << "MEDIA CHANGED in" << udi << "; size is:" << size;
2006 ++
2007 ++ if (!m_deviceCache.contains(udi) && size > 0) { // we don't know the optdisc, got inserted
2008 ++ m_deviceCache.append(udi);
2009 ++ Q_EMIT deviceAdded(udi);
2010 ++ }
2011 ++
2012 ++ if (m_deviceCache.contains(udi) && size == 0) { // we know the optdisc, got removed
2013 ++ Q_EMIT deviceRemoved(udi);
2014 ++ m_deviceCache.removeAll(udi);
2015 ++ }
2016 ++}
2017 ++
2018 ++const QStringList & Manager::deviceCache()
2019 ++{
2020 ++ if (m_deviceCache.isEmpty())
2021 ++ allDevices();
2022 ++
2023 ++ return m_deviceCache;
2024 ++}
2025 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksmanager.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksmanager.h
2026 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksmanager.h 1970-01-01 01:00:00.000000000 +0100
2027 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksmanager.h 2012-06-20 13:39:24.000000000 +0200
2028 +@@ -0,0 +1,69 @@
2029 ++/*
2030 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
2031 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
2032 ++
2033 ++ This library is free software; you can redistribute it and/or
2034 ++ modify it under the terms of the GNU Lesser General Public
2035 ++ License as published by the Free Software Foundation; either
2036 ++ version 2.1 of the License, or (at your option) version 3, or any
2037 ++ later version accepted by the membership of KDE e.V. (or its
2038 ++ successor approved by the membership of KDE e.V.), which shall
2039 ++ act as a proxy defined in Section 6 of version 3 of the license.
2040 ++
2041 ++ This library is distributed in the hope that it will be useful,
2042 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2043 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2044 ++ Lesser General Public License for more details.
2045 ++
2046 ++ You should have received a copy of the GNU Lesser General Public
2047 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2048 ++*/
2049 ++
2050 ++#ifndef UDISKS2MANAGER_H
2051 ++#define UDISKS2MANAGER_H
2052 ++
2053 ++#include "udisks2.h"
2054 ++#include "udisksdevice.h"
2055 ++#include "dbus/manager.h"
2056 ++
2057 ++#include "solid/ifaces/devicemanager.h"
2058 ++
2059 ++#include <QtDBus/QDBusInterface>
2060 ++#include <QtCore/QSet>
2061 ++
2062 ++namespace Solid
2063 ++{
2064 ++namespace Backends
2065 ++{
2066 ++namespace UDisks2
2067 ++{
2068 ++
2069 ++class Manager: public Solid::Ifaces::DeviceManager
2070 ++{
2071 ++ Q_OBJECT
2072 ++
2073 ++public:
2074 ++ Manager(QObject *parent);
2075 ++ virtual QObject* createDevice(const QString& udi);
2076 ++ virtual QStringList devicesFromQuery(const QString& parentUdi, Solid::DeviceInterface::Type type);
2077 ++ virtual QStringList allDevices();
2078 ++ virtual QSet< Solid::DeviceInterface::Type > supportedInterfaces() const;
2079 ++ virtual QString udiPrefix() const;
2080 ++ virtual ~Manager();
2081 ++
2082 ++private Q_SLOTS:
2083 ++ void slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties);
2084 ++ void slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
2085 ++ void slotMediaChanged(const QDBusMessage &msg);
2086 ++
2087 ++private:
2088 ++ const QStringList &deviceCache();
2089 ++ QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
2090 ++ org::freedesktop::DBus::ObjectManager m_manager;
2091 ++ QStringList m_deviceCache;
2092 ++};
2093 ++
2094 ++}
2095 ++}
2096 ++}
2097 ++#endif // UDISKS2MANAGER_H
2098 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldisc.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldisc.cpp
2099 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldisc.cpp 1970-01-01 01:00:00.000000000 +0100
2100 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldisc.cpp 2012-06-20 13:39:24.000000000 +0200
2101 +@@ -0,0 +1,277 @@
2102 ++/*
2103 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
2104 ++ Copyright 2010 - 2012 Lukáš Tinkl <ltinkl@××××××.com>
2105 ++
2106 ++ This library is free software; you can redistribute it and/or
2107 ++ modify it under the terms of the GNU Lesser General Public
2108 ++ License as published by the Free Software Foundation; either
2109 ++ version 2.1 of the License, or (at your option) version 3, or any
2110 ++ later version accepted by the membership of KDE e.V. (or its
2111 ++ successor approved by the membership of KDE e.V.), which shall
2112 ++ act as a proxy defined in Section 6 of version 3 of the license.
2113 ++
2114 ++ This library is distributed in the hope that it will be useful,
2115 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2116 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2117 ++ Lesser General Public License for more details.
2118 ++
2119 ++ You should have received a copy of the GNU Lesser General Public
2120 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2121 ++*/
2122 ++
2123 ++#include <sys/types.h>
2124 ++#include <unistd.h>
2125 ++#include <sys/stat.h>
2126 ++#include <fcntl.h>
2127 ++
2128 ++#include <QtCore/QFile>
2129 ++#include <QtDBus/QDBusConnection>
2130 ++
2131 ++#include "../shared/udevqtclient.h"
2132 ++
2133 ++#include "udisks2.h"
2134 ++#include "udisksopticaldisc.h"
2135 ++
2136 ++// inspired by http://cgit.freedesktop.org/hal/tree/hald/linux/probing/probe-volume.c
2137 ++static Solid::OpticalDisc::ContentType advancedDiscDetect(const QByteArray & device_file)
2138 ++{
2139 ++ /* the discs block size */
2140 ++ unsigned short bs;
2141 ++ /* the path table size */
2142 ++ unsigned short ts;
2143 ++ /* the path table location (in blocks) */
2144 ++ unsigned int tl;
2145 ++ /* length of the directory name in current path table entry */
2146 ++ unsigned char len_di = 0;
2147 ++ /* the number of the parent directory's path table entry */
2148 ++ unsigned int parent = 0;
2149 ++ /* filename for the current path table entry */
2150 ++ char dirname[256];
2151 ++ /* our position into the path table */
2152 ++ int pos = 0;
2153 ++ /* the path table record we're on */
2154 ++ int curr_record = 1;
2155 ++
2156 ++ Solid::OpticalDisc::ContentType result = Solid::OpticalDisc::NoContent;
2157 ++
2158 ++ int fd = open(device_file.constData(), O_RDONLY);
2159 ++
2160 ++ /* read the block size */
2161 ++ lseek (fd, 0x8080, SEEK_CUR);
2162 ++ if (read (fd, &bs, 2) != 2)
2163 ++ {
2164 ++ qDebug("Advanced probing on %s failed while reading block size", qPrintable(device_file));
2165 ++ goto out;
2166 ++ }
2167 ++
2168 ++ /* read in size of path table */
2169 ++ lseek (fd, 2, SEEK_CUR);
2170 ++ if (read (fd, &ts, 2) != 2)
2171 ++ {
2172 ++ qDebug("Advanced probing on %s failed while reading path table size", qPrintable(device_file));
2173 ++ goto out;
2174 ++ }
2175 ++
2176 ++ /* read in which block path table is in */
2177 ++ lseek (fd, 6, SEEK_CUR);
2178 ++ if (read (fd, &tl, 4) != 4)
2179 ++ {
2180 ++ qDebug("Advanced probing on %s failed while reading path table block", qPrintable(device_file));
2181 ++ goto out;
2182 ++ }
2183 ++
2184 ++ /* seek to the path table */
2185 ++ lseek (fd, bs * tl, SEEK_SET);
2186 ++
2187 ++ /* loop through the path table entries */
2188 ++ while (pos < ts)
2189 ++ {
2190 ++ /* get the length of the filename of the current entry */
2191 ++ if (read (fd, &len_di, 1) != 1)
2192 ++ {
2193 ++ qDebug("Advanced probing on %s failed, cannot read more entries", qPrintable(device_file));
2194 ++ break;
2195 ++ }
2196 ++
2197 ++ /* get the record number of this entry's parent
2198 ++ i'm pretty sure that the 1st entry is always the top directory */
2199 ++ lseek (fd, 5, SEEK_CUR);
2200 ++ if (read (fd, &parent, 2) != 2)
2201 ++ {
2202 ++ qDebug("Advanced probing on %s failed, couldn't read parent entry", qPrintable(device_file));
2203 ++ break;
2204 ++ }
2205 ++
2206 ++ /* read the name */
2207 ++ if (read (fd, dirname, len_di) != len_di)
2208 ++ {
2209 ++ qDebug("Advanced probing on %s failed, couldn't read the entry name", qPrintable(device_file));
2210 ++ break;
2211 ++ }
2212 ++ dirname[len_di] = 0;
2213 ++
2214 ++ /* if we found a folder that has the root as a parent, and the directory name matches
2215 ++ one of the special directories then set the properties accordingly */
2216 ++ if (parent == 1)
2217 ++ {
2218 ++ if (!strcasecmp (dirname, "VIDEO_TS"))
2219 ++ {
2220 ++ qDebug("Disc in %s is a Video DVD", qPrintable(device_file));
2221 ++ result = Solid::OpticalDisc::VideoDvd;
2222 ++ break;
2223 ++ }
2224 ++ else if (!strcasecmp (dirname, "BDMV"))
2225 ++ {
2226 ++ qDebug("Disc in %s is a Blu-ray video disc", qPrintable(device_file));
2227 ++ result = Solid::OpticalDisc::VideoBluRay;
2228 ++ break;
2229 ++ }
2230 ++ else if (!strcasecmp (dirname, "VCD"))
2231 ++ {
2232 ++ qDebug("Disc in %s is a Video CD", qPrintable(device_file));
2233 ++ result = Solid::OpticalDisc::VideoCd;
2234 ++ break;
2235 ++ }
2236 ++ else if (!strcasecmp (dirname, "SVCD"))
2237 ++ {
2238 ++ qDebug("Disc in %s is a Super Video CD", qPrintable(device_file));
2239 ++ result = Solid::OpticalDisc::SuperVideoCd;
2240 ++ break;
2241 ++ }
2242 ++ }
2243 ++
2244 ++ /* all path table entries are padded to be even,
2245 ++ so if this is an odd-length table, seek a byte to fix it */
2246 ++ if (len_di%2 == 1)
2247 ++ {
2248 ++ lseek (fd, 1, SEEK_CUR);
2249 ++ pos++;
2250 ++ }
2251 ++
2252 ++ /* update our position */
2253 ++ pos += 8 + len_di;
2254 ++ curr_record++;
2255 ++ }
2256 ++
2257 ++ close(fd);
2258 ++ return result;
2259 ++
2260 ++out:
2261 ++ /* go back to the start of the file */
2262 ++ lseek (fd, 0, SEEK_SET);
2263 ++ close(fd);
2264 ++ return result;
2265 ++}
2266 ++
2267 ++using namespace Solid::Backends::UDisks2;
2268 ++
2269 ++OpticalDisc::OpticalDisc(Device *dev)
2270 ++ : StorageVolume(dev), m_needsReprobe(true), m_cachedContent(Solid::OpticalDisc::NoContent)
2271 ++{
2272 ++ UdevQt::Client client(this);
2273 ++ m_udevDevice = client.deviceByDeviceFile(device());
2274 ++ //qDebug() << "udev device:" << m_udevDevice.name() << "valid:" << m_udevDevice.isValid();
2275 ++ /*qDebug() << "\tProperties:" << */ m_udevDevice.deviceProperties(); // initialize the properties DB so that it doesn't crash further down, #298416
2276 ++
2277 ++ m_drive = new Device(m_device->prop("Drive").value<QDBusObjectPath>().path());
2278 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, m_drive->udi(), DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
2279 ++ SLOT(slotDrivePropertiesChanged(QString,QVariantMap,QStringList)));
2280 ++}
2281 ++
2282 ++OpticalDisc::~OpticalDisc()
2283 ++{
2284 ++ delete m_drive;
2285 ++}
2286 ++
2287 ++qulonglong OpticalDisc::capacity() const
2288 ++{
2289 ++ return m_device->prop("Size").toULongLong();
2290 ++}
2291 ++
2292 ++bool OpticalDisc::isRewritable() const
2293 ++{
2294 ++ // the hard way, udisks has no notion of a disc "rewritability"
2295 ++ const QString mediaType = media();
2296 ++ return mediaType == "optical_cd_rw" || mediaType == "optical_dvd_rw" || mediaType == "optical_dvd_ram" ||
2297 ++ mediaType == "optical_dvd_plus_rw" || mediaType == "optical_dvd_plus_rw_dl" ||
2298 ++ mediaType == "optical_bd_re" || mediaType == "optical_hddvd_rw";
2299 ++}
2300 ++
2301 ++bool OpticalDisc::isBlank() const
2302 ++{
2303 ++ return m_drive->prop("OpticalBlank").toBool();
2304 ++}
2305 ++
2306 ++bool OpticalDisc::isAppendable() const
2307 ++{
2308 ++ //qDebug() << "appendable prop" << m_udevDevice.deviceProperty("ID_CDROM_MEDIA_STATE");
2309 ++ return m_udevDevice.deviceProperty("ID_CDROM_MEDIA_STATE").toString() == QLatin1String("appendable");
2310 ++}
2311 ++
2312 ++Solid::OpticalDisc::DiscType OpticalDisc::discType() const
2313 ++{
2314 ++ QMap<Solid::OpticalDisc::DiscType, QString> map;
2315 ++ map[Solid::OpticalDisc::CdRom] = "optical_cd";
2316 ++ map[Solid::OpticalDisc::CdRecordable] = "optical_cd_r";
2317 ++ map[Solid::OpticalDisc::CdRewritable] = "optical_cd_rw";
2318 ++ map[Solid::OpticalDisc::DvdRom] = "optical_dvd";
2319 ++ map[Solid::OpticalDisc::DvdRecordable] = "optical_dvd_r";
2320 ++ map[Solid::OpticalDisc::DvdRewritable] ="optical_dvd_rw";
2321 ++ map[Solid::OpticalDisc::DvdRam] ="optical_dvd_ram";
2322 ++ map[Solid::OpticalDisc::DvdPlusRecordable] ="optical_dvd_plus_r";
2323 ++ map[Solid::OpticalDisc::DvdPlusRewritable] ="optical_dvd_plus_rw";
2324 ++ map[Solid::OpticalDisc::DvdPlusRecordableDuallayer] ="optical_dvd_plus_r_dl";
2325 ++ map[Solid::OpticalDisc::DvdPlusRewritableDuallayer] ="optical_dvd_plus_rw_dl";
2326 ++ map[Solid::OpticalDisc::BluRayRom] ="optical_bd";
2327 ++ map[Solid::OpticalDisc::BluRayRecordable] ="optical_bd_r";
2328 ++ map[Solid::OpticalDisc::BluRayRewritable] ="optical_bd_re";
2329 ++ map[Solid::OpticalDisc::HdDvdRom] ="optical_hddvd";
2330 ++ map[Solid::OpticalDisc::HdDvdRecordable] ="optical_hddvd_r";
2331 ++ map[Solid::OpticalDisc::HdDvdRewritable] ="optical_hddvd_rw";
2332 ++ // TODO add these to Solid
2333 ++ //map[Solid::OpticalDisc::MagnetoOptical] ="optical_mo";
2334 ++ //map[Solid::OpticalDisc::MountRainer] ="optical_mrw";
2335 ++ //map[Solid::OpticalDisc::MountRainerWritable] ="optical_mrw_w";
2336 ++
2337 ++ return map.key(media(), Solid::OpticalDisc::UnknownDiscType); // FIXME optimize, lookup by value, not key
2338 ++}
2339 ++
2340 ++Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const
2341 ++{
2342 ++ if (isBlank()) {
2343 ++ m_needsReprobe = false;
2344 ++ return Solid::OpticalDisc::NoContent;
2345 ++ }
2346 ++
2347 ++ if (m_needsReprobe) {
2348 ++ m_cachedContent = Solid::OpticalDisc::NoContent;
2349 ++ const bool hasData = m_drive->prop("OpticalNumDataTracks").toUInt() > 0;
2350 ++ const bool hasAudio = m_drive->prop("OpticalNumAudioTracks").toUInt() > 0;
2351 ++
2352 ++ if ( hasData ) {
2353 ++ m_cachedContent |= Solid::OpticalDisc::Data;
2354 ++ m_cachedContent |= advancedDiscDetect(m_device->prop("Device").toByteArray());
2355 ++ }
2356 ++ if ( hasAudio )
2357 ++ m_cachedContent |= Solid::OpticalDisc::Audio;
2358 ++
2359 ++ m_needsReprobe = false;
2360 ++ }
2361 ++
2362 ++ return m_cachedContent;
2363 ++}
2364 ++
2365 ++void OpticalDisc::slotDrivePropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps)
2366 ++{
2367 ++ Q_UNUSED(ifaceName);
2368 ++
2369 ++ if (changedProps.keys().contains("Media") || invalidatedProps.contains("Media")) {
2370 ++ m_needsReprobe = true;
2371 ++ m_cachedContent = Solid::OpticalDisc::NoContent;
2372 ++ }
2373 ++}
2374 ++
2375 ++QString OpticalDisc::media() const
2376 ++{
2377 ++ return m_drive->prop("Media").toString();
2378 ++}
2379 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldisc.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldisc.h
2380 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldisc.h 1970-01-01 01:00:00.000000000 +0100
2381 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldisc.h 2012-06-20 13:39:24.000000000 +0200
2382 +@@ -0,0 +1,69 @@
2383 ++/*
2384 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
2385 ++ Copyright 2010 - 2012 Lukáš Tinkl <ltinkl@××××××.com>
2386 ++
2387 ++ This library is free software; you can redistribute it and/or
2388 ++ modify it under the terms of the GNU Lesser General Public
2389 ++ License as published by the Free Software Foundation; either
2390 ++ version 2.1 of the License, or (at your option) version 3, or any
2391 ++ later version accepted by the membership of KDE e.V. (or its
2392 ++ successor approved by the membership of KDE e.V.), which shall
2393 ++ act as a proxy defined in Section 6 of version 3 of the license.
2394 ++
2395 ++ This library is distributed in the hope that it will be useful,
2396 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2397 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2398 ++ Lesser General Public License for more details.
2399 ++
2400 ++ You should have received a copy of the GNU Lesser General Public
2401 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2402 ++*/
2403 ++
2404 ++#ifndef UDISKS2OPTICALDISC_H
2405 ++#define UDISKS2OPTICALDISC_H
2406 ++
2407 ++#include <solid/ifaces/opticaldisc.h>
2408 ++
2409 ++#include "../shared/udevqtdevice.h"
2410 ++
2411 ++#include "udisksstoragevolume.h"
2412 ++#include "udisksdevice.h"
2413 ++
2414 ++namespace Solid
2415 ++{
2416 ++namespace Backends
2417 ++{
2418 ++namespace UDisks2
2419 ++{
2420 ++
2421 ++class OpticalDisc: public StorageVolume, virtual public Solid::Ifaces::OpticalDisc
2422 ++{
2423 ++ Q_OBJECT
2424 ++ Q_INTERFACES(Solid::Ifaces::OpticalDisc)
2425 ++
2426 ++public:
2427 ++ OpticalDisc(Device *dev);
2428 ++ virtual ~OpticalDisc();
2429 ++
2430 ++ virtual qulonglong capacity() const;
2431 ++ virtual bool isRewritable() const;
2432 ++ virtual bool isBlank() const;
2433 ++ virtual bool isAppendable() const;
2434 ++ virtual Solid::OpticalDisc::DiscType discType() const;
2435 ++ virtual Solid::OpticalDisc::ContentTypes availableContent() const;
2436 ++
2437 ++private Q_SLOTS:
2438 ++ void slotDrivePropertiesChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps);
2439 ++
2440 ++private:
2441 ++ QString media() const;
2442 ++ mutable bool m_needsReprobe;
2443 ++ mutable Solid::OpticalDisc::ContentTypes m_cachedContent;
2444 ++ Device * m_drive;
2445 ++ UdevQt::Device m_udevDevice;
2446 ++};
2447 ++
2448 ++}
2449 ++}
2450 ++}
2451 ++#endif // UDISKS2OPTICALDISC_H
2452 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldrive.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldrive.cpp
2453 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldrive.cpp 1970-01-01 01:00:00.000000000 +0100
2454 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldrive.cpp 2012-06-20 13:39:24.000000000 +0200
2455 +@@ -0,0 +1,188 @@
2456 ++/*
2457 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
2458 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
2459 ++
2460 ++ This library is free software; you can redistribute it and/or
2461 ++ modify it under the terms of the GNU Lesser General Public
2462 ++ License as published by the Free Software Foundation; either
2463 ++ version 2.1 of the License, or (at your option) version 3, or any
2464 ++ later version accepted by the membership of KDE e.V. (or its
2465 ++ successor approved by the membership of KDE e.V.), which shall
2466 ++ act as a proxy defined in Section 6 of version 3 of the license.
2467 ++
2468 ++ This library is distributed in the hope that it will be useful,
2469 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2470 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2471 ++ Lesser General Public License for more details.
2472 ++
2473 ++ You should have received a copy of the GNU Lesser General Public
2474 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2475 ++*/
2476 ++
2477 ++#include <sys/types.h>
2478 ++#include <sys/stat.h>
2479 ++#include <fcntl.h>
2480 ++#include <string.h>
2481 ++#include <errno.h>
2482 ++#include <unistd.h>
2483 ++#include <stdlib.h>
2484 ++
2485 ++#include <QtCore/QFile>
2486 ++#include <QtCore/QDebug>
2487 ++
2488 ++#include "udisksopticaldrive.h"
2489 ++#include "udisks2.h"
2490 ++#include "udisksdevice.h"
2491 ++
2492 ++using namespace Solid::Backends::UDisks2;
2493 ++
2494 ++OpticalDrive::OpticalDrive(Device *device)
2495 ++ : StorageDrive(device), m_ejectInProgress(false), m_readSpeed(0), m_writeSpeed(0), m_speedsInit(false)
2496 ++{
2497 ++ m_device->registerAction("eject", this,
2498 ++ SLOT(slotEjectRequested()),
2499 ++ SLOT(slotEjectDone(int, const QString&)));
2500 ++
2501 ++ connect(m_device, SIGNAL(changed()), this, SLOT(slotChanged()));
2502 ++}
2503 ++
2504 ++OpticalDrive::~OpticalDrive()
2505 ++{
2506 ++}
2507 ++
2508 ++bool OpticalDrive::eject()
2509 ++{
2510 ++ if (m_ejectInProgress)
2511 ++ return false;
2512 ++ m_ejectInProgress = true;
2513 ++ m_device->broadcastActionRequested("eject");
2514 ++
2515 ++ QDBusConnection c = QDBusConnection::systemBus();
2516 ++
2517 ++ QString path = m_device->udi();
2518 ++
2519 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path, UD2_DBUS_INTERFACE_DRIVE, "Eject");
2520 ++ msg << QVariantMap();
2521 ++ return c.callWithCallback(msg, this, SLOT(slotDBusReply(const QDBusMessage &)), SLOT(slotDBusError(const QDBusError &)));
2522 ++}
2523 ++
2524 ++void OpticalDrive::slotDBusReply(const QDBusMessage &/*reply*/)
2525 ++{
2526 ++ m_ejectInProgress = false;
2527 ++ m_device->broadcastActionDone("eject");
2528 ++}
2529 ++
2530 ++void OpticalDrive::slotDBusError(const QDBusError &error)
2531 ++{
2532 ++ m_ejectInProgress = false;
2533 ++ m_device->broadcastActionDone("eject", m_device->errorToSolidError(error.name()),
2534 ++ m_device->errorToString(error.name()) + ": " +error.message());
2535 ++}
2536 ++
2537 ++void OpticalDrive::slotEjectRequested()
2538 ++{
2539 ++ m_ejectInProgress = true;
2540 ++ Q_EMIT ejectRequested(m_device->udi());
2541 ++}
2542 ++
2543 ++void OpticalDrive::slotEjectDone(int error, const QString &errorString)
2544 ++{
2545 ++ m_ejectInProgress = false;
2546 ++ Q_EMIT ejectDone(static_cast<Solid::ErrorType>(error), errorString, m_device->udi());
2547 ++}
2548 ++
2549 ++void OpticalDrive::initReadWriteSpeeds() const
2550 ++{
2551 ++#if 0
2552 ++ int read_speed, write_speed;
2553 ++ char *write_speeds = 0;
2554 ++ QByteArray device_file = QFile::encodeName(m_device->property("Device").toString());
2555 ++
2556 ++ //qDebug("Doing open (\"%s\", O_RDONLY | O_NONBLOCK)", device_file.constData());
2557 ++ int fd = open(device_file, O_RDONLY | O_NONBLOCK);
2558 ++ if (fd < 0) {
2559 ++ qWarning("Cannot open %s: %s", device_file.constData(), strerror (errno));
2560 ++ return;
2561 ++ }
2562 ++
2563 ++ if (get_read_write_speed(fd, &read_speed, &write_speed, &write_speeds) >= 0) {
2564 ++ m_readSpeed = read_speed;
2565 ++ m_writeSpeed = write_speed;
2566 ++
2567 ++ QStringList list = QString::fromLatin1(write_speeds).split(',', QString::SkipEmptyParts);
2568 ++ Q_FOREACH (const QString & speed, list)
2569 ++ m_writeSpeeds.append(speed.toInt());
2570 ++
2571 ++ free(write_speeds);
2572 ++
2573 ++ m_speedsInit = true;
2574 ++ }
2575 ++
2576 ++ close(fd);
2577 ++#endif
2578 ++}
2579 ++
2580 ++QList<int> OpticalDrive::writeSpeeds() const
2581 ++{
2582 ++ if (!m_speedsInit)
2583 ++ initReadWriteSpeeds();
2584 ++ //qDebug() << "solid write speeds:" << m_writeSpeeds;
2585 ++ return m_writeSpeeds;
2586 ++}
2587 ++
2588 ++int OpticalDrive::writeSpeed() const
2589 ++{
2590 ++ if (!m_speedsInit)
2591 ++ initReadWriteSpeeds();
2592 ++ return m_writeSpeed;
2593 ++}
2594 ++
2595 ++int OpticalDrive::readSpeed() const
2596 ++{
2597 ++ if (!m_speedsInit)
2598 ++ initReadWriteSpeeds();
2599 ++ return m_readSpeed;
2600 ++}
2601 ++
2602 ++Solid::OpticalDrive::MediumTypes OpticalDrive::supportedMedia() const
2603 ++{
2604 ++ const QStringList mediaTypes = m_device->prop("MediaCompatibility").toStringList();
2605 ++ Solid::OpticalDrive::MediumTypes supported;
2606 ++
2607 ++ QMap<Solid::OpticalDrive::MediumType, QString> map;
2608 ++ map[Solid::OpticalDrive::Cdr] = "optical_cd_r";
2609 ++ map[Solid::OpticalDrive::Cdrw] = "optical_cd_rw";
2610 ++ map[Solid::OpticalDrive::Dvd] = "optical_dvd";
2611 ++ map[Solid::OpticalDrive::Dvdr] = "optical_dvd_r";
2612 ++ map[Solid::OpticalDrive::Dvdrw] ="optical_dvd_rw";
2613 ++ map[Solid::OpticalDrive::Dvdram] ="optical_dvd_ram";
2614 ++ map[Solid::OpticalDrive::Dvdplusr] ="optical_dvd_plus_r";
2615 ++ map[Solid::OpticalDrive::Dvdplusrw] ="optical_dvd_plus_rw";
2616 ++ map[Solid::OpticalDrive::Dvdplusdl] ="optical_dvd_plus_r_dl";
2617 ++ map[Solid::OpticalDrive::Dvdplusdlrw] ="optical_dvd_plus_rw_dl";
2618 ++ map[Solid::OpticalDrive::Bd] ="optical_bd";
2619 ++ map[Solid::OpticalDrive::Bdr] ="optical_bd_r";
2620 ++ map[Solid::OpticalDrive::Bdre] ="optical_bd_re";
2621 ++ map[Solid::OpticalDrive::HdDvd] ="optical_hddvd";
2622 ++ map[Solid::OpticalDrive::HdDvdr] ="optical_hddvd_r";
2623 ++ map[Solid::OpticalDrive::HdDvdrw] ="optical_hddvd_rw";
2624 ++ // TODO add these to Solid
2625 ++ //map[Solid::OpticalDrive::Mo] ="optical_mo";
2626 ++ //map[Solid::OpticalDrive::Mr] ="optical_mrw";
2627 ++ //map[Solid::OpticalDrive::Mrw] ="optical_mrw_w";
2628 ++
2629 ++ Q_FOREACH ( const Solid::OpticalDrive::MediumType & type, map.keys() )
2630 ++ {
2631 ++ if ( mediaTypes.contains( map[type] ) )
2632 ++ {
2633 ++ supported |= type;
2634 ++ }
2635 ++ }
2636 ++
2637 ++ return supported;
2638 ++}
2639 ++
2640 ++void OpticalDrive::slotChanged()
2641 ++{
2642 ++ m_speedsInit = false; // reset the read/write speeds, changes eg. with an inserted media
2643 ++}
2644 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldrive.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldrive.h
2645 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksopticaldrive.h 1970-01-01 01:00:00.000000000 +0100
2646 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksopticaldrive.h 2012-06-20 13:39:24.000000000 +0200
2647 +@@ -0,0 +1,81 @@
2648 ++/*
2649 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
2650 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
2651 ++
2652 ++ This library is free software; you can redistribute it and/or
2653 ++ modify it under the terms of the GNU Lesser General Public
2654 ++ License as published by the Free Software Foundation; either
2655 ++ version 2.1 of the License, or (at your option) version 3, or any
2656 ++ later version accepted by the membership of KDE e.V. (or its
2657 ++ successor approved by the membership of KDE e.V.), which shall
2658 ++ act as a proxy defined in Section 6 of version 3 of the license.
2659 ++
2660 ++ This library is distributed in the hope that it will be useful,
2661 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2662 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2663 ++ Lesser General Public License for more details.
2664 ++
2665 ++ You should have received a copy of the GNU Lesser General Public
2666 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2667 ++*/
2668 ++
2669 ++#ifndef UDISKS2OPTICALDRIVE_H
2670 ++#define UDISKS2OPTICALDRIVE_H
2671 ++
2672 ++#include <solid/ifaces/opticaldrive.h>
2673 ++#include "udisksstoragedrive.h"
2674 ++
2675 ++namespace Solid
2676 ++{
2677 ++namespace Backends
2678 ++{
2679 ++namespace UDisks2
2680 ++{
2681 ++
2682 ++class OpticalDrive: public StorageDrive, virtual public Solid::Ifaces::OpticalDrive
2683 ++{
2684 ++ Q_OBJECT
2685 ++ Q_INTERFACES(Solid::Ifaces::OpticalDrive)
2686 ++
2687 ++public:
2688 ++ OpticalDrive(Device *device);
2689 ++ virtual ~OpticalDrive();
2690 ++
2691 ++Q_SIGNALS:
2692 ++ void ejectPressed(const QString &udi);
2693 ++ void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
2694 ++ void ejectRequested(const QString &udi);
2695 ++
2696 ++public:
2697 ++ virtual bool eject();
2698 ++ virtual QList<int> writeSpeeds() const;
2699 ++ virtual int writeSpeed() const;
2700 ++ virtual int readSpeed() const;
2701 ++ virtual Solid::OpticalDrive::MediumTypes supportedMedia() const;
2702 ++
2703 ++private Q_SLOTS:
2704 ++ void slotDBusReply(const QDBusMessage &reply);
2705 ++ void slotDBusError(const QDBusError &error);
2706 ++
2707 ++ void slotEjectRequested();
2708 ++ void slotEjectDone(int error, const QString &errorString);
2709 ++
2710 ++ void slotChanged();
2711 ++
2712 ++private:
2713 ++ void initReadWriteSpeeds() const;
2714 ++
2715 ++ bool m_ejectInProgress;
2716 ++
2717 ++ // read/write speeds
2718 ++ mutable int m_readSpeed;
2719 ++ mutable int m_writeSpeed;
2720 ++ mutable QList<int> m_writeSpeeds;
2721 ++ mutable bool m_speedsInit;
2722 ++};
2723 ++
2724 ++}
2725 ++}
2726 ++}
2727 ++
2728 ++#endif // UDISKS2OPTICALDRIVE_H
2729 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstorageaccess.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstorageaccess.cpp
2730 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstorageaccess.cpp 1970-01-01 01:00:00.000000000 +0100
2731 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstorageaccess.cpp 2012-06-20 13:39:24.000000000 +0200
2732 +@@ -0,0 +1,359 @@
2733 ++/*
2734 ++ Copyright 2009 Pino Toscano <pino@×××.org>
2735 ++ Copyright 2009-2012 Lukáš Tinkl <ltinkl@××××××.com>
2736 ++
2737 ++ This library is free software; you can redistribute it and/or
2738 ++ modify it under the terms of the GNU Lesser General Public
2739 ++ License as published by the Free Software Foundation; either
2740 ++ version 2.1 of the License, or (at your option) version 3, or any
2741 ++ later version accepted by the membership of KDE e.V. (or its
2742 ++ successor approved by the membership of KDE e.V.), which shall
2743 ++ act as a proxy defined in Section 6 of version 3 of the license.
2744 ++
2745 ++ This library is distributed in the hope that it will be useful,
2746 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
2747 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2748 ++ Lesser General Public License for more details.
2749 ++
2750 ++ You should have received a copy of the GNU Lesser General Public
2751 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
2752 ++*/
2753 ++
2754 ++#include "udisksstorageaccess.h"
2755 ++#include "udisks2.h"
2756 ++
2757 ++#include <QtCore/QProcess>
2758 ++#include <QtDBus/QtDBus>
2759 ++#include <QtGui/QApplication>
2760 ++#include <QtGui/QWidget>
2761 ++
2762 ++using namespace Solid::Backends::UDisks2;
2763 ++
2764 ++StorageAccess::StorageAccess(Device *device)
2765 ++ : DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false), m_passphraseRequested(false)
2766 ++{
2767 ++ updateCache();
2768 ++ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, m_device->udi(), DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
2769 ++ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList)));
2770 ++
2771 ++ // Delay connecting to DBus signals to avoid the related time penalty
2772 ++ // in hot paths such as predicate matching
2773 ++ QTimer::singleShot(0, this, SLOT(connectDBusSignals()));
2774 ++}
2775 ++
2776 ++StorageAccess::~StorageAccess()
2777 ++{
2778 ++}
2779 ++
2780 ++void StorageAccess::connectDBusSignals()
2781 ++{
2782 ++ m_device->registerAction("setup", this,
2783 ++ SLOT(slotSetupRequested()),
2784 ++ SLOT(slotSetupDone(int, const QString&)));
2785 ++
2786 ++ m_device->registerAction("teardown", this,
2787 ++ SLOT(slotTeardownRequested()),
2788 ++ SLOT(slotTeardownDone(int, const QString&)));
2789 ++}
2790 ++
2791 ++bool StorageAccess::isLuksDevice() const
2792 ++{
2793 ++ return m_device->isEncryptedContainer(); // encrypted device
2794 ++}
2795 ++
2796 ++bool StorageAccess::isAccessible() const
2797 ++{
2798 ++ if (isLuksDevice()) { // check if the cleartext slave is mounted
2799 ++ if (m_clearTextPath.isEmpty() || m_clearTextPath == "/")
2800 ++ return false;
2801 ++ Device holderDevice(m_clearTextPath);
2802 ++ return holderDevice.isMounted();
2803 ++ }
2804 ++
2805 ++ return m_device->isMounted();
2806 ++}
2807 ++
2808 ++QString StorageAccess::filePath() const
2809 ++{
2810 ++ if (!isAccessible())
2811 ++ return QString();
2812 ++
2813 ++ QByteArrayList mntPoints;
2814 ++
2815 ++ if (isLuksDevice()) { // encrypted (and unlocked) device
2816 ++ if (m_clearTextPath.isEmpty() || m_clearTextPath == "/")
2817 ++ return QString();
2818 ++ Device holderDevice(m_clearTextPath);
2819 ++ mntPoints = qdbus_cast<QByteArrayList>(holderDevice.prop("MountPoints"));
2820 ++ if (!mntPoints.isEmpty())
2821 ++ return QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
2822 ++ else
2823 ++ return QString();
2824 ++ }
2825 ++
2826 ++ mntPoints = qdbus_cast<QByteArrayList>(m_device->prop("MountPoints"));
2827 ++
2828 ++ if (!mntPoints.isEmpty())
2829 ++ return QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
2830 ++ else
2831 ++ return QString();
2832 ++}
2833 ++
2834 ++bool StorageAccess::isIgnored() const
2835 ++{
2836 ++ return m_device->prop("HintIgnore").toBool(); // FIXME tune
2837 ++}
2838 ++
2839 ++bool StorageAccess::setup()
2840 ++{
2841 ++ if ( m_teardownInProgress || m_setupInProgress )
2842 ++ return false;
2843 ++ m_setupInProgress = true;
2844 ++ m_device->broadcastActionRequested("setup");
2845 ++
2846 ++ if (m_device->isEncryptedContainer())
2847 ++ return requestPassphrase();
2848 ++ else
2849 ++ return mount();
2850 ++}
2851 ++
2852 ++bool StorageAccess::teardown()
2853 ++{
2854 ++ if ( m_teardownInProgress || m_setupInProgress )
2855 ++ return false;
2856 ++ m_teardownInProgress = true;
2857 ++ m_device->broadcastActionRequested("teardown");
2858 ++
2859 ++ return unmount();
2860 ++}
2861 ++
2862 ++void StorageAccess::slotPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps)
2863 ++{
2864 ++ Q_UNUSED(ifaceName);
2865 ++
2866 ++ if (changedProps.keys().contains("MountPoints") || invalidatedProps.contains("MountPoints")) {
2867 ++ Q_EMIT accessibilityChanged(isAccessible(), isLuksDevice() ? m_clearTextPath : m_device->udi());
2868 ++ }
2869 ++}
2870 ++
2871 ++void StorageAccess::updateCache()
2872 ++{
2873 ++ m_isAccessible = isAccessible();
2874 ++}
2875 ++
2876 ++void StorageAccess::checkAccessibility()
2877 ++{
2878 ++ const bool old_isAccessible = m_isAccessible;
2879 ++ updateCache();
2880 ++
2881 ++ if (old_isAccessible != m_isAccessible) {
2882 ++ Q_EMIT accessibilityChanged(m_isAccessible, isLuksDevice() ? m_clearTextPath : m_device->udi());
2883 ++ }
2884 ++}
2885 ++
2886 ++void StorageAccess::slotDBusReply( const QDBusMessage & reply )
2887 ++{
2888 ++ if (m_setupInProgress)
2889 ++ {
2890 ++ if (isLuksDevice() && !isAccessible()) { // unlocked device, now mount it
2891 ++ if (reply.type() == QDBusMessage::ReplyMessage) // we've got a response from Unlock
2892 ++ m_clearTextPath = reply.arguments().value(0).value<QDBusObjectPath>().path();
2893 ++ mount();
2894 ++ }
2895 ++ else // Don't broadcast setupDone unless the setup is really done. (Fix kde#271156)
2896 ++ {
2897 ++ m_setupInProgress = false;
2898 ++ m_device->broadcastActionDone("setup");
2899 ++
2900 ++ checkAccessibility();
2901 ++ }
2902 ++ }
2903 ++ else if (m_teardownInProgress) // FIXME
2904 ++ {
2905 ++ if (isLuksDevice() && !m_clearTextPath.isEmpty() && m_clearTextPath != "/") // unlocked device, lock it
2906 ++ {
2907 ++ callCryptoTeardown();
2908 ++ }
2909 ++ else if (!m_clearTextPath.isEmpty() && m_clearTextPath != "/") {
2910 ++ callCryptoTeardown(true); // Lock crypted parent
2911 ++ }
2912 ++ else
2913 ++ {
2914 ++ if (m_device->prop("Ejectable").toBool() && !m_device->isOpticalDisc()) // optical drives have their Eject method
2915 ++ {
2916 ++ // try to "eject" (aka safely remove) from the (parent) drive, e.g. SD card from a reader
2917 ++ QString drivePath = m_device->prop("Drive").value<QDBusObjectPath>().path();
2918 ++ if (!drivePath.isEmpty() || drivePath != "/")
2919 ++ {
2920 ++ QDBusConnection c = QDBusConnection::systemBus();
2921 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, drivePath, UD2_DBUS_INTERFACE_DRIVE, "Eject");
2922 ++ msg << QVariantMap(); // options, unused now
2923 ++ c.call(msg, QDBus::NoBlock);
2924 ++ }
2925 ++ }
2926 ++
2927 ++ m_teardownInProgress = false;
2928 ++ m_device->broadcastActionDone("teardown");
2929 ++
2930 ++ checkAccessibility();
2931 ++ }
2932 ++ }
2933 ++}
2934 ++
2935 ++void StorageAccess::slotDBusError( const QDBusError & error )
2936 ++{
2937 ++ if (m_setupInProgress)
2938 ++ {
2939 ++ m_setupInProgress = false;
2940 ++ m_device->broadcastActionDone("setup", m_device->errorToSolidError(error.name()),
2941 ++ m_device->errorToString(error.name()) + ": " +error.message());
2942 ++
2943 ++ checkAccessibility();
2944 ++ }
2945 ++ else if (m_teardownInProgress)
2946 ++ {
2947 ++ m_teardownInProgress = false;
2948 ++ m_clearTextPath.clear();
2949 ++ m_device->broadcastActionDone("teardown", m_device->errorToSolidError(error.name()),
2950 ++ m_device->errorToString(error.name()) + ": " + error.message());
2951 ++ checkAccessibility();
2952 ++ }
2953 ++}
2954 ++
2955 ++void StorageAccess::slotSetupRequested()
2956 ++{
2957 ++ m_setupInProgress = true;
2958 ++ Q_EMIT setupRequested(m_device->udi());
2959 ++}
2960 ++
2961 ++void StorageAccess::slotSetupDone(int error, const QString &errorString)
2962 ++{
2963 ++ m_setupInProgress = false;
2964 ++ Q_EMIT setupDone(static_cast<Solid::ErrorType>(error), errorString, m_device->udi());
2965 ++}
2966 ++
2967 ++void StorageAccess::slotTeardownRequested()
2968 ++{
2969 ++ m_teardownInProgress = true;
2970 ++ Q_EMIT teardownRequested(m_device->udi());
2971 ++}
2972 ++
2973 ++void StorageAccess::slotTeardownDone(int error, const QString &errorString)
2974 ++{
2975 ++ m_teardownInProgress = false;
2976 ++ m_clearTextPath.clear();
2977 ++ Q_EMIT teardownDone(static_cast<Solid::ErrorType>(error), errorString, m_device->udi());
2978 ++}
2979 ++
2980 ++bool StorageAccess::mount()
2981 ++{
2982 ++ QString path = m_device->udi();
2983 ++
2984 ++ if (isLuksDevice()) { // mount options for the cleartext volume
2985 ++ path = m_clearTextPath;
2986 ++ }
2987 ++
2988 ++ QDBusConnection c = QDBusConnection::systemBus();
2989 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path, UD2_DBUS_INTERFACE_FILESYSTEM, "Mount");
2990 ++
2991 ++ msg << QVariantMap(); // options, unused now
2992 ++
2993 ++ return c.callWithCallback(msg, this,
2994 ++ SLOT(slotDBusReply(const QDBusMessage &)),
2995 ++ SLOT(slotDBusError(const QDBusError &)));
2996 ++}
2997 ++
2998 ++bool StorageAccess::unmount()
2999 ++{
3000 ++ QString path = m_device->udi();
3001 ++
3002 ++ if (isLuksDevice()) { // unmount options for the cleartext volume
3003 ++ path = m_clearTextPath;
3004 ++ }
3005 ++
3006 ++ QDBusConnection c = QDBusConnection::systemBus();
3007 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path, UD2_DBUS_INTERFACE_FILESYSTEM, "Unmount");
3008 ++
3009 ++ msg << QVariantMap(); // options, unused now
3010 ++
3011 ++ return c.callWithCallback(msg, this,
3012 ++ SLOT(slotDBusReply(const QDBusMessage &)),
3013 ++ SLOT(slotDBusError(const QDBusError &)),
3014 ++ s_unmountTimeout);
3015 ++}
3016 ++
3017 ++QString StorageAccess::generateReturnObjectPath()
3018 ++{
3019 ++ static int number = 1;
3020 ++
3021 ++ return "/org/kde/solid/UDisks2StorageAccess_"+QString::number(number++);
3022 ++}
3023 ++
3024 ++bool StorageAccess::requestPassphrase()
3025 ++{
3026 ++ QString udi = m_device->udi();
3027 ++ QString returnService = QDBusConnection::sessionBus().baseService();
3028 ++ m_lastReturnObject = generateReturnObjectPath();
3029 ++
3030 ++ QDBusConnection::sessionBus().registerObject(m_lastReturnObject, this, QDBusConnection::ExportScriptableSlots);
3031 ++
3032 ++ QWidget *activeWindow = QApplication::activeWindow();
3033 ++ uint wId = 0;
3034 ++ if (activeWindow!=0)
3035 ++ wId = (uint)activeWindow->winId();
3036 ++
3037 ++ QString appId = QCoreApplication::applicationName();
3038 ++
3039 ++ QDBusInterface soliduiserver("org.kde.kded5", "/modules/soliduiserver", "org.kde.SolidUiServer");
3040 ++ QDBusReply<void> reply = soliduiserver.call("showPassphraseDialog", udi, returnService,
3041 ++ m_lastReturnObject, wId, appId);
3042 ++ m_passphraseRequested = reply.isValid();
3043 ++ if (!m_passphraseRequested)
3044 ++ qWarning() << "Failed to call the SolidUiServer, D-Bus said:" << reply.error();
3045 ++
3046 ++ return m_passphraseRequested;
3047 ++}
3048 ++
3049 ++void StorageAccess::passphraseReply(const QString & passphrase)
3050 ++{
3051 ++ if (m_passphraseRequested)
3052 ++ {
3053 ++ QDBusConnection::sessionBus().unregisterObject(m_lastReturnObject);
3054 ++ m_passphraseRequested = false;
3055 ++ if (!passphrase.isEmpty())
3056 ++ callCryptoSetup(passphrase);
3057 ++ else
3058 ++ {
3059 ++ m_setupInProgress = false;
3060 ++ m_device->broadcastActionDone("setup");
3061 ++ }
3062 ++ }
3063 ++}
3064 ++
3065 ++void StorageAccess::callCryptoSetup(const QString & passphrase)
3066 ++{
3067 ++ QDBusConnection c = QDBusConnection::systemBus();
3068 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_device->udi(), UD2_DBUS_INTERFACE_ENCRYPTED, "Unlock");
3069 ++
3070 ++ msg << passphrase;
3071 ++ msg << QVariantMap(); // options, unused now
3072 ++
3073 ++ c.callWithCallback(msg, this,
3074 ++ SLOT(slotDBusReply(const QDBusMessage &)),
3075 ++ SLOT(slotDBusError(const QDBusError &)));
3076 ++}
3077 ++
3078 ++bool StorageAccess::callCryptoTeardown(bool actOnParent)
3079 ++{
3080 ++ QDBusConnection c = QDBusConnection::systemBus();
3081 ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE,
3082 ++ actOnParent ? (m_device->prop("CryptoBackingDevice").value<QDBusObjectPath>().path()) : m_device->udi(),
3083 ++ UD2_DBUS_INTERFACE_ENCRYPTED, "Lock");
3084 ++ msg << QVariantMap(); // options, unused now
3085 ++
3086 ++ m_clearTextPath.clear();
3087 ++
3088 ++ return c.callWithCallback(msg, this,
3089 ++ SLOT(slotDBusReply(const QDBusMessage &)),
3090 ++ SLOT(slotDBusError(const QDBusError &)));
3091 ++}
3092 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstorageaccess.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstorageaccess.h
3093 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstorageaccess.h 1970-01-01 01:00:00.000000000 +0100
3094 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstorageaccess.h 2012-06-20 13:39:24.000000000 +0200
3095 +@@ -0,0 +1,104 @@
3096 ++/*
3097 ++ Copyright 2009 Pino Toscano <pino@×××.org>
3098 ++ Copyright 2009-2012 Lukáš Tinkl <ltinkl@××××××.com>
3099 ++
3100 ++ This library is free software; you can redistribute it and/or
3101 ++ modify it under the terms of the GNU Lesser General Public
3102 ++ License as published by the Free Software Foundation; either
3103 ++ version 2.1 of the License, or (at your option) version 3, or any
3104 ++ later version accepted by the membership of KDE e.V. (or its
3105 ++ successor approved by the membership of KDE e.V.), which shall
3106 ++ act as a proxy defined in Section 6 of version 3 of the license.
3107 ++
3108 ++ This library is distributed in the hope that it will be useful,
3109 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
3110 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3111 ++ Lesser General Public License for more details.
3112 ++
3113 ++ You should have received a copy of the GNU Lesser General Public
3114 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3115 ++*/
3116 ++
3117 ++#ifndef UDISKS2STORAGEACCESS_H
3118 ++#define UDISKS2STORAGEACCESS_H
3119 ++
3120 ++#include <solid/ifaces/storageaccess.h>
3121 ++#include "udisksdeviceinterface.h"
3122 ++
3123 ++#include <QtDBus/QDBusMessage>
3124 ++#include <QtDBus/QDBusError>
3125 ++
3126 ++namespace Solid
3127 ++{
3128 ++namespace Backends
3129 ++{
3130 ++namespace UDisks2
3131 ++{
3132 ++class StorageAccess : public DeviceInterface, virtual public Solid::Ifaces::StorageAccess
3133 ++{
3134 ++ Q_OBJECT
3135 ++ Q_INTERFACES(Solid::Ifaces::StorageAccess)
3136 ++
3137 ++public:
3138 ++ StorageAccess(Device *device);
3139 ++ virtual ~StorageAccess();
3140 ++
3141 ++ virtual bool isAccessible() const;
3142 ++ virtual QString filePath() const;
3143 ++ virtual bool isIgnored() const;
3144 ++ virtual bool setup();
3145 ++ virtual bool teardown();
3146 ++
3147 ++Q_SIGNALS:
3148 ++ void accessibilityChanged(bool accessible, const QString &udi);
3149 ++ void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
3150 ++ void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
3151 ++ void setupRequested(const QString &udi);
3152 ++ void teardownRequested(const QString &udi);
3153 ++
3154 ++public Q_SLOTS:
3155 ++ Q_SCRIPTABLE Q_NOREPLY void passphraseReply(const QString & passphrase);
3156 ++
3157 ++private Q_SLOTS:
3158 ++ void slotPropertiesChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps);
3159 ++ void slotDBusReply(const QDBusMessage & reply);
3160 ++ void slotDBusError(const QDBusError & error);
3161 ++
3162 ++ void connectDBusSignals();
3163 ++
3164 ++ void slotSetupRequested();
3165 ++ void slotSetupDone(int error, const QString &errorString);
3166 ++ void slotTeardownRequested();
3167 ++ void slotTeardownDone(int error, const QString &errorString);
3168 ++
3169 ++private:
3170 ++ /// @return true if this device is luks and unlocked
3171 ++ bool isLuksDevice() const;
3172 ++
3173 ++ void updateCache();
3174 ++ void checkAccessibility();
3175 ++
3176 ++ bool mount();
3177 ++ bool unmount();
3178 ++
3179 ++ bool requestPassphrase();
3180 ++ void callCryptoSetup( const QString & passphrase );
3181 ++ bool callCryptoTeardown( bool actOnParent=false );
3182 ++
3183 ++ QString generateReturnObjectPath();
3184 ++
3185 ++private:
3186 ++ bool m_isAccessible;
3187 ++ bool m_setupInProgress;
3188 ++ bool m_teardownInProgress;
3189 ++ bool m_passphraseRequested;
3190 ++ QString m_lastReturnObject;
3191 ++ QString m_clearTextPath; // path to the unlocked cleartext device
3192 ++
3193 ++ static const int s_unmountTimeout = 0x7fffffff;
3194 ++};
3195 ++}
3196 ++}
3197 ++}
3198 ++
3199 ++#endif // UDISKS2STORAGEACCESS_H
3200 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragedrive.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragedrive.cpp
3201 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragedrive.cpp 1970-01-01 01:00:00.000000000 +0100
3202 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragedrive.cpp 2012-06-20 13:39:24.000000000 +0200
3203 +@@ -0,0 +1,147 @@
3204 ++/*
3205 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
3206 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
3207 ++
3208 ++ This library is free software; you can redistribute it and/or
3209 ++ modify it under the terms of the GNU Lesser General Public
3210 ++ License as published by the Free Software Foundation; either
3211 ++ version 2.1 of the License, or (at your option) version 3, or any
3212 ++ later version accepted by the membership of KDE e.V. (or its
3213 ++ successor approved by the membership of KDE e.V.), which shall
3214 ++ act as a proxy defined in Section 6 of version 3 of the license.
3215 ++
3216 ++ This library is distributed in the hope that it will be useful,
3217 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
3218 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3219 ++ Lesser General Public License for more details.
3220 ++
3221 ++ You should have received a copy of the GNU Lesser General Public
3222 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3223 ++*/
3224 ++
3225 ++#include "udisksstoragedrive.h"
3226 ++
3227 ++#include "../shared/udevqtclient.h"
3228 ++
3229 ++#include <QtCore/QDebug>
3230 ++#include <QtCore/QFile>
3231 ++
3232 ++using namespace Solid::Backends::UDisks2;
3233 ++
3234 ++StorageDrive::StorageDrive(Device *dev)
3235 ++ : Block(dev)
3236 ++{
3237 ++ UdevQt::Client client(this);
3238 ++ m_udevDevice = client.deviceByDeviceFile(device());
3239 ++ m_udevDevice.deviceProperties();
3240 ++}
3241 ++
3242 ++StorageDrive::~StorageDrive()
3243 ++{
3244 ++}
3245 ++
3246 ++qulonglong StorageDrive::size() const
3247 ++{
3248 ++ return m_device->prop("Size").toULongLong();
3249 ++}
3250 ++
3251 ++bool StorageDrive::isHotpluggable() const
3252 ++{
3253 ++ const Solid::StorageDrive::Bus _bus = bus();
3254 ++ return _bus == Solid::StorageDrive::Usb || _bus == Solid::StorageDrive::Ieee1394;
3255 ++}
3256 ++
3257 ++bool StorageDrive::isRemovable() const
3258 ++{
3259 ++ return m_device->prop("MediaRemovable").toBool() || m_device->prop("Removable").toBool();
3260 ++}
3261 ++
3262 ++Solid::StorageDrive::DriveType StorageDrive::driveType() const
3263 ++{
3264 ++ const QStringList mediaTypes = m_device->prop("MediaCompatibility").toStringList();
3265 ++
3266 ++ if ( m_device->isOpticalDrive() ) // optical disks
3267 ++ {
3268 ++ return Solid::StorageDrive::CdromDrive;
3269 ++ }
3270 ++ else if ( mediaTypes.contains( "floppy" ) )
3271 ++ {
3272 ++ return Solid::StorageDrive::Floppy;
3273 ++ }
3274 ++#if 0 // TODO add to Solid
3275 ++ else if ( mediaTypes.contains( "floppy_jaz" ) )
3276 ++ {
3277 ++ return Solid::StorageDrive::Jaz;
3278 ++ }
3279 ++ else if ( mediaTypes.contains( "floppy_zip" ) )
3280 ++ {
3281 ++ return Solid::StorageDrive::Zip;
3282 ++ }
3283 ++ else if ( mediaTypes.contains( "flash" ) )
3284 ++ {
3285 ++ return Solid::StorageDrive::Flash;
3286 ++ }
3287 ++#endif
3288 ++ else if ( mediaTypes.contains( "flash_cf" ) )
3289 ++ {
3290 ++ return Solid::StorageDrive::CompactFlash;
3291 ++ }
3292 ++ else if ( mediaTypes.contains( "flash_ms" ) )
3293 ++ {
3294 ++ return Solid::StorageDrive::MemoryStick;
3295 ++ }
3296 ++ else if ( mediaTypes.contains( "flash_sm" ) )
3297 ++ {
3298 ++ return Solid::StorageDrive::SmartMedia;
3299 ++ }
3300 ++ else if ( mediaTypes.contains( "flash_sd" ) || mediaTypes.contains( "flash_sdhc" )
3301 ++ || mediaTypes.contains( "flash_mmc" ) || mediaTypes.contains("flash_sdxc") )
3302 ++ {
3303 ++ return Solid::StorageDrive::SdMmc;
3304 ++ }
3305 ++ // FIXME: udisks2 doesn't know about xD cards
3306 ++ else
3307 ++ {
3308 ++ return Solid::StorageDrive::HardDisk;
3309 ++ }
3310 ++}
3311 ++
3312 ++Solid::StorageDrive::Bus StorageDrive::bus() const
3313 ++{
3314 ++ const QString bus = m_device->prop("ConnectionBus").toString();
3315 ++ const QString udevBus = m_udevDevice.deviceProperty("ID_BUS").toString();
3316 ++
3317 ++ //qDebug() << "bus:" << bus << "udev bus:" << udevBus;
3318 ++
3319 ++ if (udevBus == "ata")
3320 ++ {
3321 ++ if (m_udevDevice.deviceProperty("ID_ATA_SATA").toInt() == 1) // serial ATA
3322 ++ return Solid::StorageDrive::Sata;
3323 ++ else // parallel (classical) ATA
3324 ++ return Solid::StorageDrive::Ide;
3325 ++ }
3326 ++ else if (bus == "usb")
3327 ++ {
3328 ++ return Solid::StorageDrive::Usb;
3329 ++ }
3330 ++ else if (bus == "ieee1394")
3331 ++ {
3332 ++ return Solid::StorageDrive::Ieee1394;
3333 ++ }
3334 ++ else if (udevBus == "scsi")
3335 ++ {
3336 ++ return Solid::StorageDrive::Scsi;
3337 ++ }
3338 ++#if 0 // TODO add these to Solid
3339 ++ else if ( bus == "sdio" )
3340 ++ {
3341 ++ return Solid::StorageDrive::SDIO;
3342 ++ }
3343 ++ else if ( bus == "virtual" )
3344 ++ {
3345 ++ return Solid::StorageDrive::Virtual;
3346 ++ }
3347 ++#endif
3348 ++ else
3349 ++ return Solid::StorageDrive::Platform;
3350 ++}
3351 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragedrive.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragedrive.h
3352 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragedrive.h 1970-01-01 01:00:00.000000000 +0100
3353 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragedrive.h 2012-06-20 13:39:24.000000000 +0200
3354 +@@ -0,0 +1,61 @@
3355 ++/*
3356 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
3357 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
3358 ++
3359 ++ This library is free software; you can redistribute it and/or
3360 ++ modify it under the terms of the GNU Lesser General Public
3361 ++ License as published by the Free Software Foundation; either
3362 ++ version 2.1 of the License, or (at your option) version 3, or any
3363 ++ later version accepted by the membership of KDE e.V. (or its
3364 ++ successor approved by the membership of KDE e.V.), which shall
3365 ++ act as a proxy defined in Section 6 of version 3 of the license.
3366 ++
3367 ++ This library is distributed in the hope that it will be useful,
3368 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
3369 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3370 ++ Lesser General Public License for more details.
3371 ++
3372 ++ You should have received a copy of the GNU Lesser General Public
3373 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3374 ++*/
3375 ++
3376 ++#ifndef UDISKS2STORAGEDRIVE_H
3377 ++#define UDISKS2STORAGEDRIVE_H
3378 ++
3379 ++#include <ifaces/storagedrive.h>
3380 ++
3381 ++#include "../shared/udevqtdevice.h"
3382 ++
3383 ++#include "udisksblock.h"
3384 ++
3385 ++namespace Solid
3386 ++{
3387 ++namespace Backends
3388 ++{
3389 ++namespace UDisks2
3390 ++{
3391 ++
3392 ++class StorageDrive: public Block, virtual public Solid::Ifaces::StorageDrive
3393 ++{
3394 ++ Q_OBJECT
3395 ++ Q_INTERFACES(Solid::Ifaces::StorageDrive)
3396 ++
3397 ++public:
3398 ++ StorageDrive(Device *dev);
3399 ++ virtual ~StorageDrive();
3400 ++
3401 ++ virtual qulonglong size() const;
3402 ++ virtual bool isHotpluggable() const;
3403 ++ virtual bool isRemovable() const;
3404 ++ virtual Solid::StorageDrive::DriveType driveType() const;
3405 ++ virtual Solid::StorageDrive::Bus bus() const;
3406 ++
3407 ++private:
3408 ++ UdevQt::Device m_udevDevice;
3409 ++};
3410 ++
3411 ++}
3412 ++}
3413 ++}
3414 ++
3415 ++#endif // UDISK2SSTORAGEDRIVE_H
3416 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragevolume.cpp kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragevolume.cpp
3417 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragevolume.cpp 1970-01-01 01:00:00.000000000 +0100
3418 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragevolume.cpp 2012-06-20 13:39:24.000000000 +0200
3419 +@@ -0,0 +1,105 @@
3420 ++/*
3421 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
3422 ++ Copyright 2010-2012 Lukáš Tinkl <ltinkl@××××××.com>
3423 ++
3424 ++ This library is free software; you can redistribute it and/or
3425 ++ modify it under the terms of the GNU Lesser General Public
3426 ++ License as published by the Free Software Foundation; either
3427 ++ version 2.1 of the License, or (at your option) version 3, or any
3428 ++ later version accepted by the membership of KDE e.V. (or its
3429 ++ successor approved by the membership of KDE e.V.), which shall
3430 ++ act as a proxy defined in Section 6 of version 3 of the license.
3431 ++
3432 ++ This library is distributed in the hope that it will be useful,
3433 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
3434 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3435 ++ Lesser General Public License for more details.
3436 ++
3437 ++ You should have received a copy of the GNU Lesser General Public
3438 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3439 ++*/
3440 ++
3441 ++#include "udisksstoragevolume.h"
3442 ++#include "udisks2.h"
3443 ++
3444 ++using namespace Solid::Backends::UDisks2;
3445 ++
3446 ++StorageVolume::StorageVolume(Device *device)
3447 ++ : Block(device)
3448 ++{
3449 ++}
3450 ++
3451 ++StorageVolume::~StorageVolume()
3452 ++{
3453 ++}
3454 ++
3455 ++QString StorageVolume::encryptedContainerUdi() const
3456 ++{
3457 ++ const QString path = m_device->prop("CryptoBackingDevice").value<QDBusObjectPath>().path();
3458 ++ if ( path.isEmpty() || path == "/")
3459 ++ return QString();
3460 ++ else
3461 ++ return path;
3462 ++}
3463 ++
3464 ++qulonglong StorageVolume::size() const
3465 ++{
3466 ++ return m_device->prop("Size").toULongLong();
3467 ++}
3468 ++
3469 ++QString StorageVolume::uuid() const
3470 ++{
3471 ++ return m_device->prop("IdUUID").toString();
3472 ++}
3473 ++
3474 ++QString StorageVolume::label() const
3475 ++{
3476 ++ QString label = m_device->prop("HintName").toString();
3477 ++ if (label.isEmpty())
3478 ++ label = m_device->prop("IdLabel").toString();
3479 ++ if (label.isEmpty())
3480 ++ label = m_device->prop("Name").toString();
3481 ++ return label;
3482 ++}
3483 ++
3484 ++QString StorageVolume::fsType() const
3485 ++{
3486 ++ return m_device->prop("IdType").toString();
3487 ++}
3488 ++
3489 ++Solid::StorageVolume::UsageType StorageVolume::usage() const
3490 ++{
3491 ++ const QString usage = m_device->prop("IdUsage").toString();
3492 ++
3493 ++ if (m_device->hasInterface(UD2_DBUS_INTERFACE_FILESYSTEM))
3494 ++ {
3495 ++ return Solid::StorageVolume::FileSystem;
3496 ++ }
3497 ++ else if (m_device->isPartitionTable())
3498 ++ {
3499 ++ return Solid::StorageVolume::PartitionTable;
3500 ++ }
3501 ++ else if (usage == "raid")
3502 ++ {
3503 ++ return Solid::StorageVolume::Raid;
3504 ++ }
3505 ++ else if (m_device->isEncryptedContainer())
3506 ++ {
3507 ++ return Solid::StorageVolume::Encrypted;
3508 ++ }
3509 ++ else if (usage == "unused" || usage.isEmpty())
3510 ++ {
3511 ++ return Solid::StorageVolume::Unused;
3512 ++ }
3513 ++ else
3514 ++ {
3515 ++ return Solid::StorageVolume::Other;
3516 ++ }
3517 ++}
3518 ++
3519 ++bool StorageVolume::isIgnored() const
3520 ++{
3521 ++ const Solid::StorageVolume::UsageType usg = usage();
3522 ++ return m_device->prop("HintIgnore").toBool() || m_device->isSwap() ||
3523 ++ ((usg == Solid::StorageVolume::Unused || usg == Solid::StorageVolume::Other || usg == Solid::StorageVolume::PartitionTable) && !m_device->isOpticalDisc());
3524 ++}
3525 +diff -ruN kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragevolume.h kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragevolume.h
3526 +--- kdelibs-4.8.90.orig/solid/solid/backends/udisks2/udisksstoragevolume.h 1970-01-01 01:00:00.000000000 +0100
3527 ++++ kdelibs-4.8.90/solid/solid/backends/udisks2/udisksstoragevolume.h 2012-06-20 13:39:24.000000000 +0200
3528 +@@ -0,0 +1,57 @@
3529 ++/*
3530 ++ Copyright 2010 Michael Zanetti <mzanetti@×××.org>
3531 ++
3532 ++ This library is free software; you can redistribute it and/or
3533 ++ modify it under the terms of the GNU Lesser General Public
3534 ++ License as published by the Free Software Foundation; either
3535 ++ version 2.1 of the License, or (at your option) version 3, or any
3536 ++ later version accepted by the membership of KDE e.V. (or its
3537 ++ successor approved by the membership of KDE e.V.), which shall
3538 ++ act as a proxy defined in Section 6 of version 3 of the license.
3539 ++
3540 ++ This library is distributed in the hope that it will be useful,
3541 ++ but WITHOUT ANY WARRANTY; without even the implied warranty of
3542 ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3543 ++ Lesser General Public License for more details.
3544 ++
3545 ++ You should have received a copy of the GNU Lesser General Public
3546 ++ License along with this library. If not, see <http://www.gnu.org/licenses/>.
3547 ++*/
3548 ++
3549 ++#ifndef UDISKS2STORAGEVOLUME_H
3550 ++#define UDISKS2STORAGEVOLUME_H
3551 ++
3552 ++#include <ifaces/storagevolume.h>
3553 ++#include "udisksblock.h"
3554 ++
3555 ++
3556 ++namespace Solid
3557 ++{
3558 ++namespace Backends
3559 ++{
3560 ++namespace UDisks2
3561 ++{
3562 ++
3563 ++class StorageVolume: public Block, virtual public Solid::Ifaces::StorageVolume
3564 ++{
3565 ++ Q_OBJECT
3566 ++ Q_INTERFACES(Solid::Ifaces::StorageVolume)
3567 ++
3568 ++public:
3569 ++ StorageVolume(Device *device);
3570 ++ virtual ~StorageVolume();
3571 ++
3572 ++ virtual QString encryptedContainerUdi() const;
3573 ++ virtual qulonglong size() const;
3574 ++ virtual QString uuid() const;
3575 ++ virtual QString label() const;
3576 ++ virtual QString fsType() const;
3577 ++ virtual Solid::StorageVolume::UsageType usage() const;
3578 ++ virtual bool isIgnored() const;
3579 ++};
3580 ++
3581 ++}
3582 ++}
3583 ++}
3584 ++
3585 ++#endif // UDISKS2STORAGEVOLUME_H
3586 +diff -ruN kdelibs-4.8.90.orig/solid/solid/managerbase.cpp kdelibs-4.8.90/solid/solid/managerbase.cpp
3587 +--- kdelibs-4.8.90.orig/solid/solid/managerbase.cpp 2012-05-23 01:45:29.000000000 +0200
3588 ++++ kdelibs-4.8.90/solid/solid/managerbase.cpp 2012-06-20 13:39:51.000000000 +0200
3589 +@@ -21,7 +21,7 @@
3590 + #include "managerbase_p.h"
3591 +
3592 + #include <stdlib.h>
3593 +-#if !defined (Q_WS_WIN) && !defined (Q_OS_MAC)
3594 ++#if !defined (Q_OS_WIN) && !defined (Q_OS_MAC)
3595 + #include <config-solid.h>
3596 + #endif
3597 +
3598 +@@ -30,8 +30,7 @@
3599 + #if defined (Q_OS_MAC)
3600 + #include "backends/iokit/iokitmanager.h"
3601 + #elif defined (Q_OS_UNIX)
3602 +-#include "backends/hal/halmanager.h"
3603 +-#include "backends/udisks/udisksmanager.h"
3604 ++#include "backends/udisks2/udisksmanager.h"
3605 + #include "backends/upower/upowermanager.h"
3606 +
3607 + #if defined (HUPNP_FOUND)
3608 +@@ -44,7 +43,7 @@
3609 +
3610 + #include "backends/fstab/fstabmanager.h"
3611 +
3612 +-#elif defined (Q_WS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3613 ++#elif defined (Q_OS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3614 + #include "backends/wmi/wmimanager.h"
3615 + #endif
3616 +
3617 +@@ -68,25 +67,16 @@
3618 + # if defined(Q_OS_MAC)
3619 + m_backends << new Solid::Backends::IOKit::IOKitManager(0);
3620 +
3621 +-# elif defined(Q_WS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3622 ++# elif defined(Q_OS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3623 + m_backends << new Solid::Backends::Wmi::WmiManager(0);
3624 +
3625 +-# elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
3626 +- m_backends << new Solid::Backends::Hal::HalManager(0);
3627 +-
3628 + # elif defined(Q_OS_LINUX)
3629 +- bool solidHalLegacyEnabled
3630 +- = QString::fromLocal8Bit(qgetenv("SOLID_HAL_LEGACY")).toInt()==1;
3631 +- if (solidHalLegacyEnabled) {
3632 +- m_backends << new Solid::Backends::Hal::HalManager(0);
3633 +- } else {
3634 + # if defined(UDEV_FOUND)
3635 + m_backends << new Solid::Backends::UDev::UDevManager(0);
3636 + # endif
3637 +- m_backends << new Solid::Backends::UDisks::UDisksManager(0)
3638 ++ m_backends << new Solid::Backends::UDisks2::Manager(0)
3639 + << new Solid::Backends::UPower::UPowerManager(0)
3640 + << new Solid::Backends::Fstab::FstabManager(0);
3641 +- }
3642 + # endif
3643 +
3644 + # if defined (HUPNP_FOUND)
3645 +diff -ruN kdelibs-4.8.90.orig/solid/tests/CMakeLists.txt kdelibs-4.8.90/solid/tests/CMakeLists.txt
3646 +--- kdelibs-4.8.90.orig/solid/tests/CMakeLists.txt 2012-05-23 01:45:29.000000000 +0200
3647 ++++ kdelibs-4.8.90/solid/tests/CMakeLists.txt 2012-06-20 13:39:02.000000000 +0200
3648 +@@ -16,20 +16,6 @@
3649 + add_definitions(-DTEST_DATA="\\"${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw/fakecomputer.xml\\"")
3650 +
3651 +
3652 +-########### halbasictest ###############
3653 +-
3654 +-if(NOT WIN32 AND NOT APPLE)
3655 +-set(halbasictest_SRCS halbasictest.cpp )
3656 +-
3657 +-kde4_add_executable(halbasictest ${halbasictest_SRCS})
3658 +-
3659 +-if(WIN32)
3660 +- set_target_properties(halbasictest PROPERTIES COMPILE_FLAGS -DSOLID_EXPORT=)
3661 +-endif(WIN32)
3662 +-
3663 +-target_link_libraries(halbasictest solid_static ${KDEWIN_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} )
3664 +-endif(NOT WIN32 AND NOT APPLE)
3665 +-
3666 + ########### solidhwtest ###############
3667 +
3668 + set(solidhwtest_SRCS
3669
3670 diff --git a/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_post.patch b/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_post.patch
3671 deleted file mode 100644
3672 index 68ad5f4..0000000
3673 --- a/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_post.patch
3674 +++ /dev/null
3675 @@ -1,113 +0,0 @@
3676 -diff -ruN kdelibs-4.8.90.orig/solid/solid/CMakeLists.txt kdelibs-4.8.90/solid/solid/CMakeLists.txt
3677 ---- kdelibs-4.8.90.orig/solid/solid/CMakeLists.txt 2012-06-19 22:42:38.267962759 +0200
3678 -+++ kdelibs-4.8.90/solid/solid/CMakeLists.txt 2012-06-19 22:44:23.050968201 +0200
3679 -@@ -40,7 +40,6 @@
3680 -
3681 - file(MAKE_DIRECTORY
3682 - ${CMAKE_CURRENT_BINARY_DIR}/backends/fakehw
3683 -- ${CMAKE_CURRENT_BINARY_DIR}/backends/hal
3684 - ${CMAKE_CURRENT_BINARY_DIR}/backends/udev
3685 - ${CMAKE_CURRENT_BINARY_DIR}/backends/wmi
3686 - )
3687 -@@ -226,33 +225,6 @@
3688 - endif( UDEV_FOUND )
3689 -
3690 -
3691 -- message(STATUS "Building Solid HAL backend." )
3692 -- set(solid_LIB_SRCS ${solid_LIB_SRCS}
3693 -- backends/hal/halacadapter.cpp
3694 -- backends/hal/halaudiointerface.cpp
3695 -- backends/hal/halbattery.cpp
3696 -- backends/hal/halblock.cpp
3697 -- backends/hal/halbutton.cpp
3698 -- backends/hal/halcamera.cpp
3699 -- backends/hal/halcdrom.cpp
3700 -- backends/hal/haldeviceinterface.cpp
3701 -- backends/hal/haldvbinterface.cpp
3702 -- backends/hal/halfstabhandling.cpp
3703 -- backends/hal/halgenericinterface.cpp
3704 -- backends/hal/haldevice.cpp
3705 -- backends/hal/halmanager.cpp
3706 -- backends/hal/halnetworkinterface.cpp
3707 -- backends/hal/halserialinterface.cpp
3708 -- backends/hal/halopticaldisc.cpp
3709 -- backends/hal/halportablemediaplayer.cpp
3710 -- backends/hal/halprocessor.cpp
3711 -- backends/hal/halstorageaccess.cpp
3712 -- backends/hal/halstorage.cpp
3713 -- backends/hal/halvideo.cpp
3714 -- backends/hal/halvolume.cpp
3715 -- backends/hal/halsmartcardreader.cpp
3716 -- )
3717 --
3718 - message(STATUS "Building Solid UPower backend." )
3719 - set(solid_LIB_SRCS ${solid_LIB_SRCS}
3720 - backends/upower/upowermanager.cpp
3721 -@@ -265,18 +237,19 @@
3722 -
3723 - # FIXME: this should work on more Unix systems
3724 - if (CMAKE_SYSTEM_NAME MATCHES Linux)
3725 -- message(STATUS "Building Solid UDisks backend." )
3726 -+ message(STATUS "Building Solid UDisks2 backend." )
3727 - set(solid_LIB_SRCS ${solid_LIB_SRCS}
3728 -- backends/udisks/udisksmanager.cpp
3729 -- backends/udisks/udisksdevice.cpp
3730 -- backends/udisks/udisksblock.cpp
3731 -- backends/udisks/udisksstoragevolume.cpp
3732 -- backends/udisks/udisksdeviceinterface.cpp
3733 -- backends/udisks/udisksopticaldisc.cpp
3734 -- backends/udisks/udisksopticaldrive.cpp
3735 -- backends/udisks/udisksstoragedrive.cpp
3736 -- backends/udisks/udisksstorageaccess.cpp
3737 -- backends/udisks/udisksgenericinterface.cpp
3738 -+ backends/udisks2/udisksmanager.cpp
3739 -+ backends/udisks2/udisksdevice.cpp
3740 -+ backends/udisks2/udisksblock.cpp
3741 -+ backends/udisks2/udisksstoragevolume.cpp
3742 -+ backends/udisks2/udisksdeviceinterface.cpp
3743 -+ backends/udisks2/udisksopticaldisc.cpp
3744 -+ backends/udisks2/udisksopticaldrive.cpp
3745 -+ backends/udisks2/udisksstoragedrive.cpp
3746 -+ backends/udisks2/udisksstorageaccess.cpp
3747 -+ backends/udisks2/udisksgenericinterface.cpp
3748 -+ backends/udisks2/dbus/manager.cpp
3749 - )
3750 - endif (CMAKE_SYSTEM_NAME MATCHES Linux)
3751 -
3752 -diff -ruN kdelibs-4.8.90.orig/solid/solid/managerbase.cpp kdelibs-4.8.90/solid/solid/managerbase.cpp
3753 ---- kdelibs-4.8.90.orig/solid/solid/managerbase.cpp 2012-06-19 22:42:38.267962759 +0200
3754 -+++ kdelibs-4.8.90/solid/solid/managerbase.cpp 2012-06-19 22:44:23.050968201 +0200
3755 -@@ -30,8 +30,7 @@
3756 - #if defined (Q_OS_MAC)
3757 - #include "backends/iokit/iokitmanager.h"
3758 - #elif defined (Q_OS_UNIX)
3759 --#include "backends/hal/halmanager.h"
3760 --#include "backends/udisks/udisksmanager.h"
3761 -+#include "backends/udisks2/udisksmanager.h"
3762 - #include "backends/upower/upowermanager.h"
3763 -
3764 - #if defined (HUPNP_FOUND)
3765 -@@ -71,22 +70,13 @@
3766 - # elif defined(Q_OS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3767 - m_backends << new Solid::Backends::Wmi::WmiManager(0);
3768 -
3769 --# elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
3770 -- m_backends << new Solid::Backends::Hal::HalManager(0);
3771 --
3772 - # elif defined(Q_OS_LINUX)
3773 -- bool solidHalLegacyEnabled
3774 -- = QString::fromLocal8Bit(qgetenv("SOLID_HAL_LEGACY")).toInt()==1;
3775 -- if (solidHalLegacyEnabled) {
3776 -- m_backends << new Solid::Backends::Hal::HalManager(0);
3777 -- } else {
3778 - # if defined(UDEV_FOUND)
3779 - m_backends << new Solid::Backends::UDev::UDevManager(0);
3780 - # endif
3781 -- m_backends << new Solid::Backends::UDisks::UDisksManager(0)
3782 -+ m_backends << new Solid::Backends::UDisks2::Manager(0)
3783 - << new Solid::Backends::UPower::UPowerManager(0)
3784 - << new Solid::Backends::Fstab::FstabManager(0);
3785 -- }
3786 - # endif
3787 -
3788 - # if defined (HUPNP_FOUND)
3789
3790 diff --git a/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_prep.patch b/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_prep.patch
3791 deleted file mode 100644
3792 index 2962837..0000000
3793 --- a/kde-base/kdelibs/files/kdelibs-4.8.90-udisks2_prep.patch
3794 +++ /dev/null
3795 @@ -1,65 +0,0 @@
3796 -diff -up kdelibs-4.8.2/solid/solid/CMakeLists.txt.udisks2_prep kdelibs-4.8.2/solid/solid/CMakeLists.txt
3797 ---- kdelibs-4.8.2/solid/solid/CMakeLists.txt.udisks2_prep 2011-07-27 13:34:38.000000000 -0500
3798 -+++ kdelibs-4.8.2/solid/solid/CMakeLists.txt 2012-04-17 16:02:06.153985974 -0500
3799 -@@ -1,6 +1,7 @@
3800 - set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
3801 - add_subdirectory( ifaces )
3802 - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
3803 -+include_directories( ${QT_QTDBUS_INCLUDE_DIR} )
3804 -
3805 - if(WIN32)
3806 - include_directories( ${KDEWIN_INCLUDES} )
3807 -diff -up kdelibs-4.8.2/solid/solid/managerbase.cpp.udisks2_prep kdelibs-4.8.2/solid/solid/managerbase.cpp
3808 ---- kdelibs-4.8.2/solid/solid/managerbase.cpp.udisks2_prep 2011-07-27 13:34:39.000000000 -0500
3809 -+++ kdelibs-4.8.2/solid/solid/managerbase.cpp 2012-04-17 16:02:06.154985961 -0500
3810 -@@ -21,7 +21,7 @@
3811 - #include "managerbase_p.h"
3812 -
3813 - #include <stdlib.h>
3814 --#if !defined (Q_WS_WIN) && !defined (Q_OS_MAC)
3815 -+#if !defined (Q_OS_WIN) && !defined (Q_OS_MAC)
3816 - #include <config-solid.h>
3817 - #endif
3818 -
3819 -@@ -44,7 +44,7 @@
3820 -
3821 - #include "backends/fstab/fstabmanager.h"
3822 -
3823 --#elif defined (Q_WS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3824 -+#elif defined (Q_OS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3825 - #include "backends/wmi/wmimanager.h"
3826 - #endif
3827 -
3828 -@@ -68,7 +68,7 @@ void Solid::ManagerBasePrivate::loadBack
3829 - # if defined(Q_OS_MAC)
3830 - m_backends << new Solid::Backends::IOKit::IOKitManager(0);
3831 -
3832 --# elif defined(Q_WS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3833 -+# elif defined(Q_OS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
3834 - m_backends << new Solid::Backends::Wmi::WmiManager(0);
3835 -
3836 - # elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
3837 -diff -up kdelibs-4.8.2/solid/tests/CMakeLists.txt.udisks2_prep kdelibs-4.8.2/solid/tests/CMakeLists.txt
3838 ---- kdelibs-4.8.2/solid/tests/CMakeLists.txt.udisks2_prep 2011-10-20 15:52:04.000000000 -0500
3839 -+++ kdelibs-4.8.2/solid/tests/CMakeLists.txt 2012-04-17 16:02:44.584505527 -0500
3840 -@@ -16,20 +16,6 @@ target_link_libraries(fakehardwaretest s
3841 - add_definitions(-DTEST_DATA="\\"${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw/fakecomputer.xml\\"")
3842 -
3843 -
3844 --########### halbasictest ###############
3845 --
3846 --if(NOT WIN32 AND NOT APPLE)
3847 --set(halbasictest_SRCS halbasictest.cpp )
3848 --
3849 --kde4_add_executable(halbasictest ${halbasictest_SRCS})
3850 --
3851 --if(WIN32)
3852 -- set_target_properties(halbasictest PROPERTIES COMPILE_FLAGS -DSOLID_EXPORT=)
3853 --endif(WIN32)
3854 --
3855 --target_link_libraries(halbasictest solid_static ${KDEWIN_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} )
3856 --endif(NOT WIN32 AND NOT APPLE)
3857 --
3858 - ########### solidhwtest ###############
3859 -
3860 - set(solidhwtest_SRCS
3861
3862 diff --git a/kde-base/kdelibs/kdelibs-4.8.90.ebuild b/kde-base/kdelibs/kdelibs-4.8.90.ebuild
3863 index 0a72c9e..2503764 100644
3864 --- a/kde-base/kdelibs/kdelibs-4.8.90.ebuild
3865 +++ b/kde-base/kdelibs/kdelibs-4.8.90.ebuild
3866 @@ -22,7 +22,6 @@ LICENSE="LGPL-2.1"
3867 IUSE="3dnow acl alsa altivec +bzip2 debug doc fam +handbook jpeg2k kerberos lzma
3868 mmx nls openexr +policykit semantic-desktop spell sse sse2 ssl +udev +udisks
3869 +upower upnp zeroconf"
3870 -SRC_URI+=" http://dev.gentoo.org/~dilfridge/distfiles/kdelibs-4.8.90-udisks2_backend.patch.bz2"
3871
3872 REQUIRED_USE="
3873 udisks? ( udev )
3874 @@ -130,9 +129,7 @@ PATCHES=(
3875 "${FILESDIR}/${PN}-4.8.1-norpath.patch"
3876 "${FILESDIR}/${PN}-4.8.2-calculator_key.patch"
3877 "${FILESDIR}/${PN}-4.8.4-bytecode.patch"
3878 - "${FILESDIR}/${PN}-4.8.90-udisks2_prep.patch"
3879 - "${WORKDIR}/${PN}-4.8.90-udisks2_backend.patch"
3880 - "${FILESDIR}/${PN}-4.8.90-udisks2_post.patch"
3881 + "${FILESDIR}/${PN}-4.8.90-udisks2.patch"
3882 )
3883
3884 pkg_pretend() {
3885
3886 diff --git a/kde-base/kdelibs/kdelibs-9999.ebuild b/kde-base/kdelibs/kdelibs-9999.ebuild
3887 index 7e7d1d4..219ece9 100644
3888 --- a/kde-base/kdelibs/kdelibs-9999.ebuild
3889 +++ b/kde-base/kdelibs/kdelibs-9999.ebuild
3890 @@ -22,7 +22,6 @@ LICENSE="LGPL-2.1"
3891 IUSE="3dnow acl alsa altivec +bzip2 debug doc fam +handbook jpeg2k kerberos lzma
3892 mmx nls openexr +policykit semantic-desktop spell sse sse2 ssl +udev +udisks
3893 +upower upnp zeroconf"
3894 -SRC_URI+=" http://dev.gentoo.org/~dilfridge/distfiles/kdelibs-4.8.90-udisks2_backend.patch.bz2"
3895
3896 REQUIRED_USE="
3897 udisks? ( udev )
3898 @@ -130,9 +129,7 @@ PATCHES=(
3899 "${FILESDIR}/${PN}-4.8.1-norpath.patch"
3900 "${FILESDIR}/${PN}-4.8.2-calculator_key.patch"
3901 "${FILESDIR}/${PN}-4.8.4-bytecode.patch"
3902 - "${FILESDIR}/${PN}-4.8.90-udisks2_prep.patch"
3903 - "${WORKDIR}/${PN}-4.8.90-udisks2_backend.patch"
3904 - "${FILESDIR}/${PN}-4.8.90-udisks2_post.patch"
3905 + "${FILESDIR}/${PN}-4.8.90-udisks2.patch"
3906 )
3907
3908 pkg_pretend() {