Skip to content

Commit

Permalink
Fix flash drives without partition table is not shown.
Browse files Browse the repository at this point in the history
Remove tricky logic, use IdUsage property instead.
  • Loading branch information
Mike Limansky authored and Mike Limansky committed May 17, 2012
1 parent c374a2e commit 01ecb02
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,4 +1,9 @@
TinyMount-0.2.5
---------------
- Fix flash drives without partition table is not shown.

TinyMount-0.2.4
---------------
- Add setting to hide the tray icon if there are no connected devices.

TinyMount-0.2.2
Expand Down
43 changes: 20 additions & 23 deletions src/diskmanager.cpp
Expand Up @@ -120,7 +120,9 @@ DeviceInfoPtr DiskManager::deviceForPath(const QDBusObjectPath &path)
qDebug() << dev.nativePath();
qDebug() << "\tsize =" << dev.deviceSize();
qDebug() << "\tisDrive =" << dev.deviceIsDrive();
qDebug() << "\tcanDetach =" << dev.driveCanDetach();
qDebug() << "\tisVolume =" << dev.deviceIsPartition();
qDebug() << "\tpartType =" << dev.partitionType();
qDebug() << "\tisParttable =" << dev.deviceIsPartitionTable();
qDebug() << "\tisRemovable =" << dev.deviceIsRemovable();
qDebug() << "\tisMounted =" << dev.deviceIsMounted();
Expand All @@ -135,30 +137,25 @@ DeviceInfoPtr DiskManager::deviceForPath(const QDBusObjectPath &path)

DeviceInfoPtr d;

if (dev.deviceIsPartition() || dev.deviceIsOpticalDisc())
if (dev.idUsage() == "filesystem")
{
if (dev.partitionType() != "0x05" // extended partition
&& dev.partitionType() != "0x0f" // extended Win95 partition
&& dev.idType() != "swap" // skip swap
)
{
d = DeviceInfoPtr(new DeviceInfo);

d->udisksPath = path.path();
const QString& label = dev.idLabel();
const QString& fn = dev.deviceFile();
d->name = label.isEmpty() ? fn.mid(fn.lastIndexOf('/') + 1) : label;
d->size = dev.deviceSize();
d->fileSystem = dev.idType();
d->type = dev.deviceIsSystemInternal() ? DeviceInfo::HDD :
dev.deviceIsOpticalDisc() ? DeviceInfo::CD :
dev.driveMediaCompatibility().contains("floppy") ? DeviceInfo::Floppy :
containsFlashTypes(dev.driveMediaCompatibility()) ? DeviceInfo::Flash :
DeviceInfo::Other;
d->isMounted = dev.deviceIsMounted();
if (d->isMounted) d->mountPoint = dev.deviceMountPaths().first();
d->isSystem = dev.deviceIsSystemInternal();
}
qDebug() << "3333333333";
d = DeviceInfoPtr(new DeviceInfo);

d->udisksPath = path.path();
const QString& label = dev.idLabel();
const QString& fn = dev.deviceFile();
d->name = label.isEmpty() ? fn.mid(fn.lastIndexOf('/') + 1) : label;
d->size = dev.deviceSize();
d->fileSystem = dev.idType();
d->type = dev.deviceIsSystemInternal() ? DeviceInfo::HDD :
dev.deviceIsOpticalDisc() ? DeviceInfo::CD :
dev.driveMediaCompatibility().contains("floppy") ? DeviceInfo::Floppy :
containsFlashTypes(dev.driveMediaCompatibility()) ? DeviceInfo::Flash :
DeviceInfo::Other;
d->isMounted = dev.deviceIsMounted();
if (d->isMounted) d->mountPoint = dev.deviceMountPaths().first();
d->isSystem = dev.deviceIsSystemInternal();
}

return d;
Expand Down
2 changes: 1 addition & 1 deletion src/src.pro
Expand Up @@ -19,7 +19,7 @@

TEMPLATE = app
TARGET = tinymount
VERSION = 0.2.4
VERSION = 0.2.5

DEPENDPATH += .
INCLUDEPATH += .
Expand Down

0 comments on commit 01ecb02

Please sign in to comment.