~lubuntu-dev/lxde/liblxqt-mount

« back to all changes in this revision

Viewing changes to rzmountproviders.h

  • Committer: Luís Pereira
  • Date: 2014-06-12 10:52:04 UTC
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: git-v1:09b968dfd1434bfe6eae98496a1f1e38db8d471d
Changes files names

This change has in mind how to include the header using portable headers
way.

Signed-off-by: Luís Pereira <luis.artur.pereira@gmail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* BEGIN_COMMON_COPYRIGHT_HEADER
2
 
 * (c)LGPL2+
3
 
 *
4
 
 * LXQt - The Lightweight Desktop Environment
5
 
 * http://lxqt.org
6
 
 *
7
 
 * Copyright: 2012 Razor team
8
 
 *            2013-2014 LXQt team
9
 
 * Authors:
10
 
 *   Alexander Sokoloff <sokoloff.a@gmail.com>
11
 
 *   Petr Vanek <petr@scribus.info>
12
 
 *
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.
17
 
 *
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.
22
 
 
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
27
 
 *
28
 
 * END_COMMON_COPYRIGHT_HEADER */
29
 
 
30
 
 
31
 
#ifndef LXQTMOUNT_RZMOUNTPROVIDERS_H
32
 
#define LXQTMOUNT_RZMOUNTPROVIDERS_H
33
 
 
34
 
#include <QObject>
35
 
#include "lxqtmount.h"
36
 
#include <QtDBus/QDBusObjectPath>
37
 
class QDBusInterface;
38
 
class QDBusMessage;
39
 
class QDBusError;
40
 
 
41
 
namespace LxQt {
42
 
 
43
 
class MountProvider : public QObject
44
 
{
45
 
    Q_OBJECT
46
 
public:
47
 
    explicit MountProvider(QObject *parent = 0);
48
 
    virtual ~MountProvider() {}
49
 
 
50
 
    const MountDeviceList devices() const { return mDevices; }
51
 
 
52
 
    bool isValid() const { return mIsValid; }
53
 
    virtual void update()=0;
54
 
 
55
 
signals:
56
 
    void deviceAdded(LxQt::MountDevice *device);
57
 
    void deviceRemoved(LxQt::MountDevice *device);
58
 
    void deviceChanged(LxQt::MountDevice *device);
59
 
 
60
 
protected:
61
 
    MountDeviceList mDevices;
62
 
    bool mIsValid;
63
 
};
64
 
 
65
 
 
66
 
 
67
 
class UDiskMountDevice: public MountDevice
68
 
{
69
 
    Q_OBJECT
70
 
public:
71
 
    UDiskMountDevice(const QDBusObjectPath &path);
72
 
    bool update();
73
 
    QString udiskPath() const { return mUdiskPath; }
74
 
 
75
 
    virtual bool mount();
76
 
    virtual bool unmount();
77
 
    virtual bool eject();
78
 
 
79
 
private:
80
 
    QDBusInterface *mDbus;
81
 
    QString mUdiskPath;
82
 
 
83
 
    MediaType calcMediaType();
84
 
    QString calcLabel();
85
 
    bool calcIsExternal();
86
 
    QString calcIconName();
87
 
 
88
 
private slots:
89
 
    void dbusError(const QDBusError &err, const QDBusMessage &msg);
90
 
};
91
 
 
92
 
 
93
 
 
94
 
class UDiskProvider: public MountProvider
95
 
{
96
 
    Q_OBJECT
97
 
public:
98
 
    explicit UDiskProvider(QObject *parent = 0);
99
 
 
100
 
    virtual void update();
101
 
 
102
 
private slots:
103
 
    void dbusDeviceAdded(const QDBusObjectPath &path);
104
 
    void dbusDeviceRemoved(const QDBusObjectPath &path);
105
 
    void dbusDeviceChanged(const QDBusObjectPath &path);
106
 
 
107
 
private:
108
 
    QHash<QString, UDiskMountDevice*> mDevicesByPath;
109
 
    UDiskMountDevice *getDevice(const QDBusObjectPath &path) const;
110
 
 
111
 
    void addDevice(UDiskMountDevice *device);
112
 
    void delDevice(UDiskMountDevice *device);
113
 
};
114
 
 
115
 
 
116
 
 
117
 
class UDisks2MountDevice: public MountDevice
118
 
{
119
 
    Q_OBJECT
120
 
public:
121
 
    UDisks2MountDevice(const QDBusObjectPath &path);
122
 
    QDBusObjectPath path() { return mPath; }
123
 
 
124
 
    virtual bool mount();
125
 
    virtual bool unmount();
126
 
    virtual bool eject();
127
 
 
128
 
private:
129
 
    QDBusInterface *mBlockIface;
130
 
    QDBusInterface *mDriveIface;
131
 
    QDBusObjectPath mPath;
132
 
 
133
 
    MediaType calcMediaType();
134
 
    QString calcLabel();
135
 
    bool calcIsExternal();
136
 
    QString calcIconName();
137
 
    QStringList mountPoints() const;
138
 
 
139
 
 
140
 
private slots:
141
 
    void dbusError(const QDBusError &err, const QDBusMessage &msg);
142
 
    void aboutToMount();
143
 
    void aboutToUnmount();
144
 
    void aboutToEject();
145
 
    void update();
146
 
};
147
 
 
148
 
 
149
 
 
150
 
class UDisks2Provider: public MountProvider
151
 
{
152
 
    Q_OBJECT
153
 
public:
154
 
    explicit UDisks2Provider(QObject *parent = 0);
155
 
 
156
 
    virtual void update();
157
 
 
158
 
public slots:
159
 
    void dbusDeviceChanged(const QDBusObjectPath &path);
160
 
 
161
 
private slots:
162
 
    void dbusDeviceAdded(const QDBusObjectPath &path, const QVariantMap &map);
163
 
    void dbusDeviceRemoved(const QDBusObjectPath &path, const QStringList &list);
164
 
 
165
 
private:
166
 
    QHash<QString, UDisks2MountDevice*> mDevicesByPath;
167
 
    UDisks2MountDevice *getDevice(const QDBusObjectPath &path) const;
168
 
 
169
 
    void addDevice(UDisks2MountDevice *device);
170
 
    void delDevice(UDisks2MountDevice *device);
171
 
};
172
 
 
173
 
} // namespace LxQt
174
 
 
175
 
#endif // LXQTMOUNT_RZMOUNTPROVIDERS_H