Skip to content

Commit

Permalink
fixed: unmounted CDs not showing up as sources on linux systems with …
Browse files Browse the repository at this point in the history
…UDisks

This is required for audio CDs to show up as sources and restores the
ability to browse iso9660 discs without mounting them on linux systems
using UDisks.

This was seemingly broken in r23628.

(cherry picked from commit e7c51b0154b41af3fa8f1cbd9c619f991d1c655d)

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@33271 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information
anssih committed Aug 28, 2010
1 parent 2e2bbaa commit 4dfb2e5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
64 changes: 40 additions & 24 deletions xbmc/linux/UDisksProvider.cpp
Expand Up @@ -37,40 +37,50 @@ CUDiskDevice::CUDiskDevice(const char *DeviceKitUDI)
m_isPartition = false;
m_isFileSystem = false;
m_isSystemInternal = false;
m_isOptical = false;
m_PartitionSizeGiB = 0.0f;
Update();
}

void CUDiskDevice::Update()
{
CStdString str = CDBusUtil::GetVariant("org.freedesktop.UDisks", m_DeviceKitUDI.c_str(), "org.freedesktop.UDisks.Device", "IdUsage").asString();
m_isFileSystem = str.Equals("filesystem");
CVariant properties = CDBusUtil::GetAll("org.freedesktop.UDisks", m_DeviceKitUDI.c_str(), "org.freedesktop.UDisks.Device");

m_isFileSystem = CStdString(properties["IdUsage"].asString()) == "filesystem";
if (m_isFileSystem)
{
CVariant properties = CDBusUtil::GetAll("org.freedesktop.UDisks", m_DeviceKitUDI.c_str(), "org.freedesktop.UDisks.Device");

m_UDI = properties["IdUuid"].asString();
m_Label = properties["IdLabel"].asString();
m_FileSystem = properties["IdType"].asString();
if (properties["DeviceMountPaths"].size() > 0)
m_MountPath = properties["DeviceMountPaths"][0].asString();
m_isMounted = properties["DeviceIsMounted"].asBoolean();

m_PartitionSizeGiB = properties["PartitionSize"].asUnsignedInteger() / 1024.0 / 1024.0 / 1024.0;
m_isPartition = properties["DeviceIsPartition"].asBoolean();
m_isSystemInternal = properties["DeviceIsSystemInternal"].asBoolean();
if (m_isPartition)
{
CVariant isRemovable = CDBusUtil::GetVariant("org.freedesktop.UDisks", properties["PartitionSlave"].asString(), "org.freedesktop.UDisks.Device", "DeviceIsRemovable");
}
else
{
m_UDI.clear();
m_Label.clear();
m_FileSystem.clear();
}

if ( !isRemovable.isNull() )
m_isRemovable = isRemovable.asBoolean();
else
m_isRemovable = false;
}
m_isMounted = properties["DeviceIsMounted"].asBoolean();
if (m_isMounted && properties["DeviceMountPaths"].size() > 0)
m_MountPath = properties["DeviceMountPaths"][0].asString();
else
m_MountPath.clear();

m_PartitionSizeGiB = properties["PartitionSize"].asUnsignedInteger() / 1024.0 / 1024.0 / 1024.0;
m_isPartition = properties["DeviceIsPartition"].asBoolean();
m_isSystemInternal = properties["DeviceIsSystemInternal"].asBoolean();
m_isOptical = properties["DeviceIsOpticalDisc"].asBoolean();
if (m_isPartition)
{
CVariant isRemovable = CDBusUtil::GetVariant("org.freedesktop.UDisks", properties["PartitionSlave"].asString(), "org.freedesktop.UDisks.Device", "DeviceIsRemovable");

if ( !isRemovable.isNull() )
m_isRemovable = isRemovable.asBoolean();
else
m_isRemovable = properties["DeviceIsRemovable"].asBoolean();
m_isRemovable = false;
}
else
m_isRemovable = properties["DeviceIsRemovable"].asBoolean();
}

bool CUDiskDevice::Mount()
Expand Down Expand Up @@ -132,14 +142,19 @@ CMediaSource CUDiskDevice::ToMediaShare()
source.strName.Format("%.1f GB %s", m_PartitionSizeGiB, g_localizeStrings.Get(155).c_str());
else
source.strName = m_Label;
source.m_iDriveType = !m_isSystemInternal ? CMediaSource::SOURCE_TYPE_REMOVABLE : CMediaSource::SOURCE_TYPE_LOCAL;
if (m_isOptical)
source.m_iDriveType = CMediaSource::SOURCE_TYPE_DVD;
else if (m_isSystemInternal)
source.m_iDriveType = CMediaSource::SOURCE_TYPE_LOCAL;
else
source.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOVABLE;
source.m_ignore = true;
return source;
}

bool CUDiskDevice::IsApproved()
{
return (m_isFileSystem && m_isMounted && m_UDI.length() > 0 && (m_FileSystem.length() > 0 && !m_FileSystem.Equals("swap")) && !m_MountPath.Equals("/"));
return (m_isFileSystem && m_isMounted && m_UDI.length() > 0 && (m_FileSystem.length() > 0 && !m_FileSystem.Equals("swap")) && !m_MountPath.Equals("/")) || m_isOptical;
}

#define BOOL2SZ(b) ((b) ? "true" : "false")
Expand All @@ -148,10 +163,11 @@ CStdString CUDiskDevice::toString()
{
CStdString str;
str.Format("DeviceUDI %s: IsFileSystem %s HasFileSystem %s "
"IsSystemInternal %s IsMounted %s IsRemovable %s IsPartition %s",
"IsSystemInternal %s IsMounted %s IsRemovable %s IsPartition %s "
"IsOptical %s",
m_DeviceKitUDI.c_str(), BOOL2SZ(m_isFileSystem), m_FileSystem,
BOOL2SZ(m_isSystemInternal), BOOL2SZ(m_isMounted),
BOOL2SZ(m_isRemovable), BOOL2SZ(m_isPartition));
BOOL2SZ(m_isRemovable), BOOL2SZ(m_isPartition), BOOL2SZ(m_isOptical));

return str;
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/linux/UDisksProvider.h
Expand Up @@ -41,7 +41,7 @@ class CUDiskDevice
CMediaSource ToMediaShare();

CStdString m_UDI, m_DeviceKitUDI, m_MountPath, m_FileSystem, m_Label;
bool m_isMounted, m_isMountedByUs, m_isRemovable, m_isPartition, m_isFileSystem, m_isSystemInternal;
bool m_isMounted, m_isMountedByUs, m_isRemovable, m_isPartition, m_isFileSystem, m_isSystemInternal, m_isOptical;
float m_PartitionSizeGiB;
};

Expand Down

0 comments on commit 4dfb2e5

Please sign in to comment.