-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisks.h
87 lines (73 loc) · 2.15 KB
/
disks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
# Copyright (c) 2018, Ole-André Rodlie <ole.andre.rodlie@gmail.com> All rights reserved.
#
# Available under the 3-clause BSD license
# See the LICENSE file for full details
*/
#ifndef DISKS_H
#define DISKS_H
#include <QObject>
#include <QMap>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QTimer>
class Device : public QObject
{
Q_OBJECT
public:
explicit Device(const QString block, QObject *parent = NULL);
QString name;
QString path;
QString dev;
QString drive;
QString mountpoint;
QString filesystem;
bool isOptical;
bool isRemovable;
bool hasMedia;
int opticalDataTracks;
int opticalAudioTracks;
bool isBlankDisc;
bool hasPartition;
private:
QDBusInterface *dbus;
signals:
void mediaChanged(QString devicePath, bool mediaPresent);
void mountpointChanged(QString devicePath, QString deviceMountpoint);
void nameChanged(QString devicePath, QString deviceName);
void errorMessage(QString devicePath, QString deviceError);
public slots:
void mount();
void unmount();
void eject();
private slots:
void updateDeviceProperties();
void handlePropertiesChanged(const QString &interfaceType, const QMap<QString, QVariant> &changedProperties);
};
class Disks : public QObject
{
Q_OBJECT
public:
explicit Disks(QObject *parent = NULL);
QMap<QString, Device*> devices;
private:
QDBusInterface *dbus;
QTimer timer;
signals:
void updatedDevices();
void mediaChanged(QString path, bool media);
void mountpointChanged(QString path, QString mountpoint);
void deviceErrorMessage(QString path, QString error);
void foundNewDevice(QString path);
void removedDevice(QString path);
private slots:
void setupDBus();
void scanDevices();
void deviceAdded(const QDBusObjectPath &obj);
void deviceRemoved(const QDBusObjectPath &obj);
void handleDeviceMediaChanged(QString devicePath, bool mediaPresent);
void handleDeviceMountpointChanged(QString devicePath, QString deviceMountpoint);
void handleDeviceErrorMessage(QString devicePath, QString deviceError);
void checkUDisks();
};
#endif // DISKS_H