1
/* BEGIN_COMMON_COPYRIGHT_HEADER
4
* LXQt - The Lightweight Desktop Environment
7
* Copyright: 2012 Razor team
10
* Alexander Sokoloff <sokoloff.a@gmail.com>
11
* Petr Vanek <petr@scribus.info>
13
* This program or library is free software; you can redistribute it
14
* and/or modify it under the terms of the GNU Lesser General Public
15
* License as published by the Free Software Foundation; either
16
* version 2.1 of the License, or (at your option) any later version.
18
* This library is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
* Lesser General Public License for more details.
23
* You should have received a copy of the GNU Lesser General
24
* Public License along with this library; if not, write to the
25
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26
* Boston, MA 02110-1301 USA
28
* END_COMMON_COPYRIGHT_HEADER */
31
#ifndef LXQTMOUNT_RZMOUNTPROVIDERS_H
32
#define LXQTMOUNT_RZMOUNTPROVIDERS_H
35
#include "lxqtmount.h"
36
#include <QtDBus/QDBusObjectPath>
43
class MountProvider : public QObject
47
explicit MountProvider(QObject *parent = 0);
48
virtual ~MountProvider() {}
50
const MountDeviceList devices() const { return mDevices; }
52
bool isValid() const { return mIsValid; }
53
virtual void update()=0;
56
void deviceAdded(LxQt::MountDevice *device);
57
void deviceRemoved(LxQt::MountDevice *device);
58
void deviceChanged(LxQt::MountDevice *device);
61
MountDeviceList mDevices;
67
class UDiskMountDevice: public MountDevice
71
UDiskMountDevice(const QDBusObjectPath &path);
73
QString udiskPath() const { return mUdiskPath; }
76
virtual bool unmount();
80
QDBusInterface *mDbus;
83
MediaType calcMediaType();
85
bool calcIsExternal();
86
QString calcIconName();
89
void dbusError(const QDBusError &err, const QDBusMessage &msg);
94
class UDiskProvider: public MountProvider
98
explicit UDiskProvider(QObject *parent = 0);
100
virtual void update();
103
void dbusDeviceAdded(const QDBusObjectPath &path);
104
void dbusDeviceRemoved(const QDBusObjectPath &path);
105
void dbusDeviceChanged(const QDBusObjectPath &path);
108
QHash<QString, UDiskMountDevice*> mDevicesByPath;
109
UDiskMountDevice *getDevice(const QDBusObjectPath &path) const;
111
void addDevice(UDiskMountDevice *device);
112
void delDevice(UDiskMountDevice *device);
117
class UDisks2MountDevice: public MountDevice
121
UDisks2MountDevice(const QDBusObjectPath &path);
122
QDBusObjectPath path() { return mPath; }
124
virtual bool mount();
125
virtual bool unmount();
126
virtual bool eject();
129
QDBusInterface *mBlockIface;
130
QDBusInterface *mDriveIface;
131
QDBusObjectPath mPath;
133
MediaType calcMediaType();
135
bool calcIsExternal();
136
QString calcIconName();
137
QStringList mountPoints() const;
141
void dbusError(const QDBusError &err, const QDBusMessage &msg);
143
void aboutToUnmount();
150
class UDisks2Provider: public MountProvider
154
explicit UDisks2Provider(QObject *parent = 0);
156
virtual void update();
159
void dbusDeviceChanged(const QDBusObjectPath &path);
162
void dbusDeviceAdded(const QDBusObjectPath &path, const QVariantMap &map);
163
void dbusDeviceRemoved(const QDBusObjectPath &path, const QStringList &list);
166
QHash<QString, UDisks2MountDevice*> mDevicesByPath;
167
UDisks2MountDevice *getDevice(const QDBusObjectPath &path) const;
169
void addDevice(UDisks2MountDevice *device);
170
void delDevice(UDisks2MountDevice *device);
175
#endif // LXQTMOUNT_RZMOUNTPROVIDERS_H