~lubuntu-dev/lxde/liblxqt-mount

« back to all changes in this revision

Viewing changes to lxqtmount.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
 
 *
12
 
 * This program or library is free software; you can redistribute it
13
 
 * and/or modify it under the terms of the GNU Lesser General Public
14
 
 * License as published by the Free Software Foundation; either
15
 
 * version 2.1 of the License, or (at your option) any later version.
16
 
 *
17
 
 * This library is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
 
 * Lesser General Public License for more details.
21
 
 
22
 
 * You should have received a copy of the GNU Lesser General
23
 
 * Public License along with this library; if not, write to the
24
 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25
 
 * Boston, MA 02110-1301 USA
26
 
 *
27
 
 * END_COMMON_COPYRIGHT_HEADER */
28
 
 
29
 
 
30
 
#ifndef LXQTMOUNT_LXQTMOUNT_H
31
 
#define LXQTMOUNT_LXQTMOUNT_H
32
 
 
33
 
#include <QtCore/QObject>
34
 
#include <QtCore/QList>
35
 
 
36
 
#include <QtGlobal>
37
 
 
38
 
#ifdef COMPILE_LIBLXQT_MOUNT
39
 
#define LIBLXQT_MOUNT_API Q_DECL_EXPORT
40
 
#else
41
 
#define LIBLXQT_MOUNT_API Q_DECL_IMPORT
42
 
#endif
43
 
 
44
 
#define BOOL_SETTER(MEMBER) { bool res=(value != MEMBER); MEMBER = value; return res; }
45
 
 
46
 
namespace LxQt {
47
 
 
48
 
class MountProvider;
49
 
class LIBLXQT_MOUNT_API MountDevice: public QObject
50
 
{
51
 
    Q_OBJECT
52
 
public:
53
 
    enum MediaType {
54
 
        MediaTypeUnknown,
55
 
        MediaTypeDrive,
56
 
        MediaTypePartition,
57
 
        MediaTypeFdd,
58
 
        MediaTypeOptical
59
 
    };
60
 
 
61
 
    virtual bool mount() = 0;
62
 
    virtual bool unmount() = 0;
63
 
    virtual bool eject() = 0;
64
 
 
65
 
    QString devFile() const { return mDevFile; }
66
 
    QString label() const { return mLabel; }
67
 
    QString vendor() const { return mVendor; }
68
 
    QString model() const { return mModel; }
69
 
    QString fileSystem() const { return mFileSystem; }
70
 
    QString mountPath() const { return mMountPath; }
71
 
    QString iconName() const { return mIconName; }
72
 
 
73
 
 
74
 
    qulonglong size() const { return mSize; }
75
 
    MediaType mediaType() const { return mMediaType; }
76
 
 
77
 
    bool isValid() const { return mIsValid; }
78
 
    bool isExternal() const { return mIsExternal; }
79
 
    bool isMounted() const { return mIsMounted; }
80
 
    bool isEjectable() const { return mIsEjectable; }
81
 
 
82
 
    static QString sizeToString(qulonglong size);
83
 
signals:
84
 
     void changed();
85
 
     void error(const QString &msg);
86
 
     void mounted();
87
 
     void unmounted();
88
 
 
89
 
protected:
90
 
    explicit MountDevice();
91
 
 
92
 
    bool setDevFile(const QString &value)   BOOL_SETTER(mDevFile)
93
 
    bool setLabel(const QString &value)     BOOL_SETTER(mLabel)
94
 
    bool setVendor(const QString &value)    BOOL_SETTER(mVendor)
95
 
    bool setModel(const QString &value)     BOOL_SETTER(mModel)
96
 
    bool setFileSystem(const QString &value) BOOL_SETTER(mFileSystem)
97
 
    bool setMountPath(const QString &value) BOOL_SETTER(mMountPath)
98
 
    bool setIconName(const QString &value)  BOOL_SETTER(mIconName)
99
 
 
100
 
    bool setSize(qulonglong value)      BOOL_SETTER(mSize)
101
 
    bool setMediaType(MediaType value)  BOOL_SETTER(mMediaType)
102
 
 
103
 
    bool setIsValid(bool value)         BOOL_SETTER(mIsValid)
104
 
    bool setIsExternal(bool value)      BOOL_SETTER(mIsExternal)
105
 
    bool setIsMounted(bool value)       BOOL_SETTER(mIsMounted)
106
 
    bool setIsEjectable(bool value)     BOOL_SETTER(mIsEjectable)
107
 
 
108
 
    QString mDevFile;
109
 
    QString mLabel;
110
 
    QString mVendor;
111
 
    QString mModel;
112
 
    QString mFileSystem;
113
 
    QString mMountPath;
114
 
    QString mIconName;
115
 
 
116
 
    qulonglong mSize;
117
 
    MediaType mMediaType;
118
 
 
119
 
    bool mIsValid;
120
 
    bool mIsExternal;
121
 
    bool mIsMounted;
122
 
    bool mIsEjectable;
123
 
private:
124
 
    Q_DISABLE_COPY(MountDevice)
125
 
 
126
 
 
127
 
};
128
 
 
129
 
typedef QList<MountDevice*> MountDeviceList;
130
 
 
131
 
 
132
 
 
133
 
 
134
 
class LIBLXQT_MOUNT_API MountManager : public QObject
135
 
{
136
 
    Q_OBJECT
137
 
public:
138
 
    explicit MountManager(QObject *parent = 0);
139
 
    virtual ~MountManager();
140
 
 
141
 
    const MountDeviceList devices() const;
142
 
 
143
 
public slots:
144
 
    void update();
145
 
 
146
 
signals:
147
 
    void deviceAdded(LxQt::MountDevice *device);
148
 
    void deviceRemoved(LxQt::MountDevice *device);
149
 
    void deviceChanged(LxQt::MountDevice *device);
150
 
 
151
 
private:
152
 
    MountProvider *mProvider;
153
 
 
154
 
};
155
 
 
156
 
} // namespace LxQt
157
 
 
158
 
LIBLXQT_MOUNT_API QDebug operator<<(QDebug dbg, const LxQt::MountDevice& device);
159
 
LIBLXQT_MOUNT_API QDebug operator<<(QDebug dbg, const LxQt::MountDevice* const device);
160
 
 
161
 
#endif // LXQTMOUNT_LXQTMOUNT_H