dtkio
dtk library for dtkio.
载入中...
搜索中...
未找到
ddiskdrive.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DDISKDRIVE_H
6#define DDISKDRIVE_H
7
8#include <DtkMountGlobal>
9
10#include <QObject>
11#include <QVariantMap>
12
13#include <DExpected>
14
15DCORE_USE_NAMESPACE
16DMOUNT_BEGIN_NAMESPACE
17
18class DDiskDrive;
19namespace DDeviceManager {
20DExpected<DDiskDrive *> createDiskDrive(const QString &path, QObject *parent);
21} // namespace DDeviceManager
22
23class DDiskDrivePrivate;
24class DDiskDrive : public QObject
25{
26 Q_OBJECT
27 Q_DECLARE_PRIVATE(DDiskDrive)
28
29 Q_PROPERTY(QString path READ path CONSTANT FINAL)
30 Q_PROPERTY(bool canPowerOff READ canPowerOff CONSTANT FINAL)
31 Q_PROPERTY(QVariantMap configuration READ configuration CONSTANT FINAL)
32 Q_PROPERTY(QString connectionBus READ connectionBus CONSTANT FINAL)
33 Q_PROPERTY(bool ejectable READ ejectable CONSTANT FINAL)
34 Q_PROPERTY(QString id READ id CONSTANT FINAL)
35 Q_PROPERTY(QString media READ media CONSTANT FINAL)
36 Q_PROPERTY(bool mediaAvailable READ mediaAvailable CONSTANT FINAL)
37 Q_PROPERTY(bool mediaChangeDetected READ mediaChangeDetected CONSTANT FINAL)
38 Q_PROPERTY(QStringList mediaCompatibility READ mediaCompatibility CONSTANT FINAL)
39 Q_PROPERTY(bool mediaRemovable READ mediaRemovable CONSTANT FINAL)
40 Q_PROPERTY(QString model READ model CONSTANT FINAL)
41 Q_PROPERTY(bool optical READ optical CONSTANT FINAL)
42 Q_PROPERTY(bool opticalBlank READ opticalBlank CONSTANT FINAL)
43 Q_PROPERTY(uint opticalNumAudioTracks READ opticalNumAudioTracks CONSTANT FINAL)
44 Q_PROPERTY(uint opticalNumDataTracks READ opticalNumDataTracks CONSTANT FINAL)
45 Q_PROPERTY(uint opticalNumSessions READ opticalNumSessions CONSTANT FINAL)
46 Q_PROPERTY(uint opticalNumTracks READ opticalNumTracks CONSTANT FINAL)
47 Q_PROPERTY(bool removable READ removable CONSTANT FINAL)
48 Q_PROPERTY(QString revision READ revision CONSTANT FINAL)
49 Q_PROPERTY(int rotationRate READ rotationRate CONSTANT FINAL)
50 Q_PROPERTY(QString seat READ seat CONSTANT FINAL)
51 Q_PROPERTY(QString serial READ serial CONSTANT FINAL)
52 Q_PROPERTY(QString siblingId READ siblingId CONSTANT FINAL)
53 Q_PROPERTY(quint64 size READ size CONSTANT FINAL)
54 Q_PROPERTY(QString sortKey READ sortKey CONSTANT FINAL)
55 Q_PROPERTY(quint64 timeDetected READ timeDetected CONSTANT FINAL)
56 Q_PROPERTY(quint64 timeMediaDetected READ timeMediaDetected CONSTANT FINAL)
57 Q_PROPERTY(QString vendor READ vendor CONSTANT FINAL)
58 Q_PROPERTY(QString WWN READ WWN CONSTANT FINAL)
59
60public:
62 QString path() const;
63 bool canPowerOff() const;
64 QVariantMap configuration() const;
65 QString connectionBus() const;
66 bool ejectable() const;
67 QString id() const;
68 QString media() const;
69 bool mediaAvailable() const;
70 bool mediaChangeDetected() const;
71 QStringList mediaCompatibility() const;
72 bool mediaRemovable() const;
73 QString model() const;
74 bool optical() const;
75 bool opticalBlank() const;
78 uint opticalNumSessions() const;
79 uint opticalNumTracks() const;
80 bool removable() const;
81 QString revision() const;
82 int rotationRate() const;
83 QString seat() const;
84 QString serial() const;
85 QString siblingId() const;
86 quint64 size() const;
87 QString sortKey() const;
88 quint64 timeDetected() const;
89 quint64 timeMediaDetected() const;
90 QString vendor() const;
91 QString WWN() const;
92
93 // TODO(zhangs): lastError
94
95public Q_SLOTS:
96 void eject(const QVariantMap &options);
97 void powerOff(const QVariantMap &options);
98 void setConfiguration(const QVariantMap &value, const QVariantMap &options);
99
100protected:
101 explicit DDiskDrive(const QString &path, QObject *parent = nullptr);
102
103private:
104 QScopedPointer<DDiskDrivePrivate> d_ptr;
105
106 friend DExpected<DDiskDrive *> DDeviceManager::createDiskDrive(const QString &path, QObject *parent);
107};
108
109DMOUNT_END_NAMESPACE
110
111#endif // DDISKDRIVE_H
该类用于访问及操作设备驱动器(磁盘驱动器)
Definition ddiskdrive.h:25
uint opticalNumTracks() const
查询光盘中轨道数量,该方法仅在 optical() 为 True 时有效
~DDiskDrive()
析构函数
quint64 timeDetected() const
获取第一次检测到驱动器的时间
bool mediaRemovable() const
查询驱动设备存储介质是否为可移动设备
bool opticalBlank() const
查询光驱设备中光盘是否为空白光盘,该方法仅在 optical() 为 True 时有效
QString path() const
获取驱动设备的对象路径,形如 /org/freedesktop/UDisks/Drives/...
QString serial() const
查询驱动设备序列号
void powerOff(const QVariantMap &options)
对驱动器进行断电操作以便其可以从计算机中安全移除。若能操作陈宫,则说明没有任何进程在使用驱动器
QString revision() const
查询驱动设备硬件版本
QString seat() const
查询驱动设备插入的插槽标识符
void setConfiguration(const QVariantMap &value, const QVariantMap &options)
设置驱动器配置列表。会同时将配置信息存储到文件系统和驱动设备中
bool mediaChangeDetected() const
查询是否检测到媒介变更
QString sortKey() const
用于对驱动设备排序的键值
bool mediaAvailable() const
查询当前驱动设备内是否有存储媒介存在,通常用于查询光驱内是否有光盘
QString media() const
获取驱动设备当前存储媒介类型,在查询光驱当前光盘类型时十分有用
QString id() const
获取驱动设备唯一标识符,通常情况下,驱动设备对象路径最后一段数据即为它
QString connectionBus() const
查询驱动设备所连接的总线类型
QString model() const
查询驱动设备型号名称
QString siblingId() const
一个标识符,非空情况下可用于判定一组设备是否是同一个驱动器
QString vendor() const
获取驱动器生产厂商名称
QStringList mediaCompatibility() const
查询驱动设备所支持的物理存储介质的类型列表
QVariantMap configuration() const
查询驱动设备配置信息
quint64 timeMediaDetected() const
存储媒介检测到的时间
bool ejectable() const
查询驱动设备是否可执行弹出操作,例如光驱是可弹出托盘的
int rotationRate() const
查询设备转速
bool optical() const
查询驱动设备是否为光驱设备
uint opticalNumAudioTracks() const
查询光盘中的音频轨道数量,该方法仅在 optical() 为 True 时有效
QString WWN() const
获取驱动器全局名称(World wide name)
uint opticalNumDataTracks() const
查询光盘中数据轨道数量,该方法仅在 optical() 为 True 时有效
uint opticalNumSessions() const
查询光盘中会话数量,该方法仅在 optical() 为 True 时有效
quint64 size() const
获取驱动器或驱动器当前存储介质的容量大小
bool canPowerOff() const
查询驱动设备能否执行断电操作
void eject(const QVariantMap &options)
从驱动器中弹出存储介质,仅对“具有可移动存储介质的驱动器”有意义,例如光驱
bool removable() const
提示驱动设备或者其存储介质是否可移动
DExpected< DDiskDrive * > createDiskDrive(const QString &path, QObject *parent=nullptr)
通过驱动器路径创建驱动器对象