feat: add sketchy way to get the type of a volume.

This commit is contained in:
Chris Xiong 2019-10-11 15:57:53 +08:00
parent 5fb3db906e
commit 68d2e61e2c
3 changed files with 16 additions and 2 deletions

View File

@ -47,6 +47,7 @@ public:
~DGioVolume(); ~DGioVolume();
QString name() const; QString name() const;
QString volumeMonitorName() const;
bool canMount() const; bool canMount() const;
bool canEject() const; bool canEject() const;
bool shouldAutoMount() const; bool shouldAutoMount() const;

View File

@ -84,6 +84,17 @@ QString DGioVolume::name() const
return d->name(); return d->name();
} }
QString DGioVolume::volumeMonitorName() const
{
Q_D(const DGioVolume);
if (QString(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(d->m_gmmVolumePtr->gobj()))) == "GProxyVolume") {
return (const char*)g_object_get_data(G_OBJECT(d->m_gmmVolumePtr->gobj()), "g-proxy-volume-volume-monitor-name");
}
return "";
}
bool DGioVolume::canMount() const bool DGioVolume::canMount() const
{ {
Q_D(const DGioVolume); Q_D(const DGioVolume);

View File

@ -123,10 +123,12 @@ int main(int argc, char * argv[])
const QList<QExplicitlySharedDataPointer<DGioVolume> > vols = DGioVolumeManager::getVolumes(); const QList<QExplicitlySharedDataPointer<DGioVolume> > vols = DGioVolumeManager::getVolumes();
for (const QExplicitlySharedDataPointer<DGioVolume> &p : vols) { for (const QExplicitlySharedDataPointer<DGioVolume> &p : vols) {
qDebug() << p->name() qDebug() << p->name() << p->volumeMonitorName()
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_UUID) << p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_UUID)
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_CLASS) << p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_CLASS)
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_LABEL); << p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_LABEL)
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_NFS_MOUNT)
<< p->identifier(DGioVolumeIdentifierType::VOLUME_IDENTIFIER_TYPE_UNIX_DEVICE);
} }
qDebug() << "----------drives------------"; qDebug() << "----------drives------------";