summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2019-08-24 18:25:55 +0900
committerMichele Calgaro <[email protected]>2020-10-17 10:48:28 +0800
commitd34f23f403e82f352e4c5d4e20966bcba2bec8c6 (patch)
treea1c02a3f85d2cf018f279bca095d5012702701e5 /tdeioslave/media
parentebc4784c4fddeb307f4bc2ab83b4189312f24f3b (diff)
downloadtdebase-d34f23f403e82f352e4c5d4e20966bcba2bec8c6.tar.gz
tdebase-d34f23f403e82f352e4c5d4e20966bcba2bec8c6.zip
tdeioslave media: clean up code related to medium mountable state in preparation for further work.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tdeioslave/media')
-rw-r--r--tdeioslave/media/libmediacommon/medium.cpp202
-rw-r--r--tdeioslave/media/libmediacommon/medium.h96
-rw-r--r--tdeioslave/media/mediaimpl.cpp1
-rw-r--r--tdeioslave/media/mediamanager/fstabbackend.cpp12
-rw-r--r--tdeioslave/media/mediamanager/halbackend.cpp82
-rw-r--r--tdeioslave/media/mediamanager/medialist.cpp44
-rw-r--r--tdeioslave/media/mediamanager/removablebackend.cpp7
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp106
8 files changed, 301 insertions, 249 deletions
diff --git a/tdeioslave/media/libmediacommon/medium.cpp b/tdeioslave/media/libmediacommon/medium.cpp
index 77e32ba0f..7ded6f0f1 100644
--- a/tdeioslave/media/libmediacommon/medium.cpp
+++ b/tdeioslave/media/libmediacommon/medium.cpp
@@ -23,68 +23,57 @@
const TQString Medium::SEPARATOR = "---";
+void Medium::initMedium()
+{
+ m_properties.clear();
+ m_properties += TQString::null; // ID
+ m_properties += TQString::null; // UUID
+ m_properties += TQString::null; // NAME
+ m_properties += TQString::null; // LABEL
+ m_properties += TQString::null; // USER_LABEL
+ m_properties += "false"; // MOUNTABLE
+ m_properties += TQString::null; // DEVICE_NODE
+ m_properties += TQString::null; // MOUNT_POINT
+ m_properties += TQString::null; // FS_TYPE
+ m_properties += "false"; // MOUNTED
+ m_properties += TQString::null; // BASE_URL
+ m_properties += TQString::null; // MIME_TYPE
+ m_properties += TQString::null; // ICON_NAME
+ m_properties += "false"; // ENCRYPTED
+ m_properties += TQString::null; // CLEAR_DEVICE_UDI
+ m_properties += "false"; // HIDDEN
+ m_properties += "false"; // SOFT_HIDDEN
+}
+
Medium::Medium(const TQString id, TQString uuid, const TQString name)
{
- m_properties+= id; /* ID */
- m_properties+= uuid; /* UUID */
- m_properties+= name; /* NAME */
- m_properties+= name; /* LABEL */
- m_properties+= TQString::null; /* USER_LABEL */
-
- m_properties+= "false"; /* MOUNTABLE */
- m_properties+= TQString::null; /* DEVICE_NODE */
- m_properties+= TQString::null; /* MOUNT_POINT */
- m_properties+= TQString::null; /* FS_TYPE */
- m_properties+= "false"; /* MOUNTED */
- m_properties+= TQString::null; /* BASE_URL */
- m_properties+= TQString::null; /* MIME_TYPE */
- m_properties+= TQString::null; /* ICON_NAME */
- m_properties+= "false"; /* ENCRYPTED */
- m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */
- m_properties+= "false"; /* HIDDEN */
- m_properties+= "false"; /* SOFT_HIDDEN */
-
- loadUserLabel();
-
- m_halmounted = false;
+ initMedium();
+ if (!id.isEmpty() && !uuid.isEmpty())
+ {
+ m_properties[ID] = id;
+ m_properties[UUID] = uuid;
+ m_properties[NAME] = name;
+ m_properties[LABEL] = name;
+ loadUserLabel();
+ }
}
Medium::Medium()
{
- m_properties+= TQString::null; /* ID */
- m_properties+= TQString::null; /* UUID */
- m_properties+= TQString::null; /* NAME */
- m_properties+= TQString::null; /* LABEL */
- m_properties+= TQString::null; /* USER_LABEL */
-
- m_properties+= TQString::null; /* MOUNTABLE */
- m_properties+= TQString::null; /* DEVICE_NODE */
- m_properties+= TQString::null; /* MOUNT_POINT */
- m_properties+= TQString::null; /* FS_TYPE */
- m_properties+= TQString::null; /* MOUNTED */
- m_properties+= TQString::null; /* BASE_URL */
- m_properties+= TQString::null; /* MIME_TYPE */
- m_properties+= TQString::null; /* ICON_NAME */
- m_properties+= TQString::null; /* ENCRYPTED */
- m_properties+= TQString::null; /* CLEAR_DEVICE_UDI */
- m_properties+= "false"; /* HIDDEN */
- m_properties+= "false"; /* SOFT_HIDDEN */
-
- m_halmounted = false;
+ initMedium();
}
const Medium Medium::create(const TQStringList &properties)
{
Medium m;
- if ( properties.size() >= PROPERTIES_COUNT )
+ if (properties.size() >= PROPERTIES_COUNT)
{
m.m_properties[ID] = properties[ID];
m.m_properties[UUID] = properties[UUID];
m.m_properties[NAME] = properties[NAME];
m.m_properties[LABEL] = properties[LABEL];
m.m_properties[USER_LABEL] = properties[USER_LABEL];
-
m.m_properties[MOUNTABLE] = properties[MOUNTABLE];
m.m_properties[DEVICE_NODE] = properties[DEVICE_NODE];
m.m_properties[MOUNT_POINT] = properties[MOUNT_POINT];
@@ -106,13 +95,12 @@ Medium::MList Medium::createList(const TQStringList &properties)
{
MList l;
- if ( properties.size() % (PROPERTIES_COUNT+1) == 0)
+ if (properties.size() % (PROPERTIES_COUNT+1) == 0)
{
- int media_count = properties.size()/(PROPERTIES_COUNT+1);
-
+ int media_count = properties.size() / (PROPERTIES_COUNT + 1);
TQStringList props = properties;
- for(int i=0; i<media_count; i++)
+ for (int i=0; i < media_count; i++)
{
const Medium m = create(props);
l.append(m);
@@ -127,7 +115,6 @@ Medium::MList Medium::createList(const TQStringList &properties)
return l;
}
-
void Medium::setName(const TQString &name)
{
m_properties[NAME] = name;
@@ -138,35 +125,22 @@ void Medium::setLabel(const TQString &label)
m_properties[LABEL] = label;
}
-void Medium::setEncrypted(bool state)
-{
- m_properties[ENCRYPTED] = ( state ? "true" : "false" );
-}
-
-void Medium::setHidden(bool state)
-{
- m_properties[HIDDEN] = ( state ? "true" : "false" );
-}
-
-void Medium::setSoftHidden(bool state)
-{
- m_properties[SOFT_HIDDEN] = ( state ? "true" : "false" );
-}
-
void Medium::setUserLabel(const TQString &label)
{
TDEConfig cfg("mediamanagerrc");
cfg.setGroup("UserLabels");
TQString entry_name = m_properties[UUID];
-
- if ( label.isNull() )
- {
- cfg.deleteEntry(entry_name);
- }
- else
+ if (!entry_name.isEmpty())
{
- cfg.writeEntry(entry_name, label);
+ if (label.isEmpty())
+ {
+ cfg.deleteEntry(entry_name);
+ }
+ else
+ {
+ cfg.writeEntry(entry_name, label);
+ }
}
m_properties[USER_LABEL] = label;
@@ -178,10 +152,9 @@ void Medium::loadUserLabel()
cfg.setGroup("UserLabels");
TQString entry_name = m_properties[UUID];
-
- if ( cfg.hasKey(entry_name) )
+ if (!entry_name.isEmpty())
{
- m_properties[USER_LABEL] = cfg.readEntry(entry_name);
+ m_properties[USER_LABEL] = cfg.readEntry(entry_name, TQString::null);
}
else
{
@@ -189,48 +162,38 @@ void Medium::loadUserLabel()
}
}
-
-bool Medium::mountableState(bool mounted)
+void Medium::setMountable(bool mountable)
{
- if ( m_properties[DEVICE_NODE].isEmpty()
- || ( mounted && m_properties[MOUNT_POINT].isEmpty() ) )
+ m_properties[MOUNTABLE] = mountable ? "true" : "false";
+ if (!mountable)
{
- return false;
+ setMountPoint(TQString::null);
+ setMounted(false);
}
-
- m_properties[MOUNTABLE] = "true";
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
-
- return true;
}
-void Medium::mountableState(const TQString &deviceNode,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted)
+void Medium::setDeviceNode(const TQString &deviceNode)
{
- m_properties[MOUNTABLE] = "true";
m_properties[DEVICE_NODE] = deviceNode;
- m_properties[MOUNT_POINT] = mountPoint;
- m_properties[FS_TYPE] = fsType;
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
}
-void Medium::mountableState(const TQString &deviceNode,
- const TQString &clearDeviceUdi,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted)
+void Medium::setMountPoint(const TQString &mountPoint)
{
- m_properties[MOUNTABLE] = "true";
- m_properties[DEVICE_NODE] = deviceNode;
- m_properties[CLEAR_DEVICE_UDI] = clearDeviceUdi;
m_properties[MOUNT_POINT] = mountPoint;
+}
+
+void Medium::setFsType(const TQString &fsType)
+{
m_properties[FS_TYPE] = fsType;
- m_properties[MOUNTED] = ( mounted ? "true" : "false" );
}
-void Medium::unmountableState(const TQString &baseURL)
+void Medium::setMounted(bool mounted)
+{
+ m_properties[MOUNTED] = mounted ? "true" : "false";
+}
+
+void Medium::setBaseURL(const TQString &baseURL)
{
- m_properties[MOUNTABLE] = "false";
m_properties[BASE_URL] = baseURL;
}
@@ -244,6 +207,26 @@ void Medium::setIconName(const TQString &iconName)
m_properties[ICON_NAME] = iconName;
}
+void Medium::setEncrypted(bool state)
+{
+ m_properties[ENCRYPTED] = ( state ? "true" : "false" );
+}
+
+void Medium::setClearDeviceUdi(const TQString &clearDeviceUdi)
+{
+ m_properties[CLEAR_DEVICE_UDI] = clearDeviceUdi;
+}
+
+void Medium::setHidden(bool state)
+{
+ m_properties[HIDDEN] = ( state ? "true" : "false" );
+}
+
+void Medium::setSoftHidden(bool state)
+{
+ m_properties[SOFT_HIDDEN] = ( state ? "true" : "false" );
+}
+
bool Medium::needMounting() const
{
return isMountable() && !isMounted();
@@ -256,21 +239,20 @@ bool Medium::needDecryption() const
KURL Medium::prettyBaseURL() const
{
- if ( !baseURL().isEmpty() )
- return baseURL();
+ if (!baseURL().isEmpty())
+ {
+ return baseURL();
+ }
- return KURL( mountPoint() );
+ return KURL(mountPoint());
}
TQString Medium::prettyLabel() const
{
- if ( !userLabel().isEmpty() )
+ if (!userLabel().isEmpty())
{
return userLabel();
}
- else
- {
- return label();
- }
-}
+ return label();
+}
diff --git a/tdeioslave/media/libmediacommon/medium.h b/tdeioslave/media/libmediacommon/medium.h
index bf465fd09..7e7f2b04a 100644
--- a/tdeioslave/media/libmediacommon/medium.h
+++ b/tdeioslave/media/libmediacommon/medium.h
@@ -29,24 +29,24 @@ class Medium
public:
typedef TQValueList<Medium> MList;
- static const uint ID = 0;
- static const uint UUID = 1;
- static const uint NAME = 2;
- static const uint LABEL = 3;
- static const uint USER_LABEL = 4;
- static const uint MOUNTABLE = 5;
- static const uint DEVICE_NODE = 6;
- static const uint MOUNT_POINT = 7;
- static const uint FS_TYPE = 8;
- static const uint MOUNTED = 9;
- static const uint BASE_URL = 10;
- static const uint MIME_TYPE = 11;
- static const uint ICON_NAME = 12;
- static const uint ENCRYPTED = 13;
- static const uint CLEAR_DEVICE_UDI = 14;
- static const uint HIDDEN = 15;
- static const uint SOFT_HIDDEN = 16;
- static const uint PROPERTIES_COUNT = 17;
+ static const uint ID = 0;
+ static const uint UUID = 1;
+ static const uint NAME = 2;
+ static const uint LABEL = 3;
+ static const uint USER_LABEL = 4;
+ static const uint MOUNTABLE = 5;
+ static const uint DEVICE_NODE = 6;
+ static const uint MOUNT_POINT = 7;
+ static const uint FS_TYPE = 8;
+ static const uint MOUNTED = 9;
+ static const uint BASE_URL = 10;
+ static const uint MIME_TYPE = 11;
+ static const uint ICON_NAME = 12;
+ static const uint ENCRYPTED = 13;
+ static const uint CLEAR_DEVICE_UDI = 14;
+ static const uint HIDDEN = 15;
+ static const uint SOFT_HIDDEN = 16;
+ static const uint PROPERTIES_COUNT = 17;
static const TQString SEPARATOR;
Medium(const TQString id, TQString uuid, const TQString name);
@@ -60,18 +60,18 @@ public:
TQString name() const { return m_properties[NAME]; }
TQString label() const { return m_properties[LABEL]; }
TQString userLabel() const { return m_properties[USER_LABEL]; }
- bool isMountable() const { return m_properties[MOUNTABLE]=="true"; }
+ bool isMountable() const { return m_properties[MOUNTABLE]=="true"; }
TQString deviceNode() const { return m_properties[DEVICE_NODE]; }
TQString mountPoint() const { return m_properties[MOUNT_POINT]; }
TQString fsType() const { return m_properties[FS_TYPE]; }
- bool isMounted() const { return m_properties[MOUNTED]=="true"; }
+ bool isMounted() const { return m_properties[MOUNTED]=="true"; }
TQString baseURL() const { return m_properties[BASE_URL]; }
TQString mimeType() const { return m_properties[MIME_TYPE]; }
TQString iconName() const { return m_properties[ICON_NAME]; }
- bool isEncrypted() const { return m_properties[ENCRYPTED]=="true"; };
+ bool isEncrypted() const { return m_properties[ENCRYPTED]=="true"; };
TQString clearDeviceUdi() const { return m_properties[CLEAR_DEVICE_UDI]; };
- bool hidden() const { return m_properties[HIDDEN]=="true"; };
- bool softHidden() const { return m_properties[SOFT_HIDDEN]=="true"; };
+ bool hidden() const { return m_properties[HIDDEN]=="true"; };
+ bool softHidden() const { return m_properties[SOFT_HIDDEN]=="true"; };
bool needMounting() const;
bool needDecryption() const;
@@ -81,50 +81,44 @@ public:
void setName(const TQString &name);
void setLabel(const TQString &label);
void setUserLabel(const TQString &label);
+ void setMountable(bool mountable);
+ void setDeviceNode(const TQString &deviceNode);
+ void setMountPoint(const TQString &mountPoint);
+ void setFsType(const TQString &fsType);
+ void setMounted(bool mounted);
+ void setBaseURL(const TQString &baseURL);
+ void setMimeType(const TQString &mimeType);
+ void setIconName(const TQString &iconName);
void setEncrypted(bool state);
+ void setClearDeviceUdi(const TQString &clearDeviceUdi);
void setHidden(bool state);
void setSoftHidden(bool state);
- bool mountableState(bool mounted);
- void mountableState(const TQString &deviceNode,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted);
- void mountableState(const TQString &deviceNode,
- const TQString &clearDeviceUdi,
- const TQString &mountPoint,
- const TQString &fsType, bool mounted);
- void unmountableState(const TQString &baseURL = TQString::null);
-
- void setMimeType(const TQString &mimeType);
- void setIconName(const TQString &iconName);
- void setHalMounted(bool flag) const { m_halmounted = flag; }
- bool halMounted() const { return m_halmounted; }
-
-//private:
Medium();
private:
+ void initMedium();
void loadUserLabel();
TQStringList m_properties;
- mutable bool m_halmounted;
-friend class TQValueListNode<const Medium>;
+ friend class TQValueListNode<const Medium>;
};
namespace MediaManagerUtils {
- static inline TQMap<TQString,TQString> splitOptions(const TQStringList & options)
- {
- TQMap<TQString,TQString> valids;
-
- for (TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
+ static inline TQMap<TQString,TQString> splitOptions(const TQStringList &options)
{
- TQString key = (*it).left((*it).find('='));
- TQString value = (*it).mid((*it).find('=') + 1);
- valids[key] = value;
+ TQMap<TQString,TQString> valids;
+
+ for (TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
+ {
+ int pos = (*it).find('=');
+ TQString key = (*it).left(pos);
+ TQString value = (*it).mid(pos + 1);
+ valids[key] = value;
+ }
+ return valids;
}
- return valids;
- }
}
#endif
diff --git a/tdeioslave/media/mediaimpl.cpp b/tdeioslave/media/mediaimpl.cpp
index b92757f90..dc839c4a0 100644
--- a/tdeioslave/media/mediaimpl.cpp
+++ b/tdeioslave/media/mediaimpl.cpp
@@ -127,7 +127,6 @@ bool MediaImpl::statMediumByLabel(const TQString &label, TDEIO::UDSEntry &entry)
return statMedium(name, entry);
}
-
bool MediaImpl::listMedia(TQValueList<TDEIO::UDSEntry> &list)
{
kdDebug(1219) << "MediaImpl::listMedia" << endl;
diff --git a/tdeioslave/media/mediamanager/fstabbackend.cpp b/tdeioslave/media/mediamanager/fstabbackend.cpp
index 8eca21771..acd1dced2 100644
--- a/tdeioslave/media/mediamanager/fstabbackend.cpp
+++ b/tdeioslave/media/mediamanager/fstabbackend.cpp
@@ -220,7 +220,11 @@ void FstabBackend::handleMtabChange(bool allowNotification)
Medium *m = new Medium(id, name);
- m->mountableState(dev, mp, fs, true);
+ m->setMountable(true);
+ m->setDeviceNode(dev);
+ m->setMountPoint(mp);
+ m->setFsType(fs);
+ m->setMounted(true);
TQString mime, icon, label;
guess(dev, mp, fs, true, mime, icon, label);
@@ -293,7 +297,11 @@ void FstabBackend::handleFstabChange(bool allowNotification)
Medium *m = new Medium(id, id, name);
- m->mountableState(dev, mp, fs, false);
+ m->setMountable(true);
+ m->setDeviceNode(dev);
+ m->setMountPoint(mp);
+ m->setFsType(fs);
+ m->setMounted(false);
TQString mime, icon, label;
guess(dev, mp, fs, false, mime, icon, label);
diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp
index b6f35c997..e05b5c3e8 100644
--- a/tdeioslave/media/mediamanager/halbackend.cpp
+++ b/tdeioslave/media/mediamanager/halbackend.cpp
@@ -516,28 +516,32 @@ void HALBackend::setVolumeProperties(Medium* medium)
}
if (halClearVolume)
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- clearUdiString,
- libhal_volume_get_mount_point(halClearVolume), /* Mount point */
- libhal_volume_get_fstype(halClearVolume), /* Filesystem type */
- libhal_volume_is_mounted(halClearVolume) ); /* Mounted ? */
+ {
+ medium->setMountable(true);
+ medium->setDeviceNode(libhal_volume_get_device_file(halVolume));
+ medium->setClearDeviceUdi(clearUdiString);
+ medium->setMountPoint(libhal_volume_get_mount_point(halClearVolume));
+ medium->setFsType(libhal_volume_get_fstype(halClearVolume));
+ medium->setMounted(libhal_volume_is_mounted(halClearVolume));
+ }
else
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- TQString::null,
- TQString::null, /* Mount point */
- TQString::null, /* Filesystem type */
- false ); /* Mounted ? */
+ {
+ medium->setMountable(true);
+ medium->setDeviceNode(libhal_volume_get_device_file(halVolume));
+ medium->setClearDeviceUdi(TQString::null);
+ medium->setMountPoint(TQString::null);
+ medium->setFsType(TQString::null);
+ medium->setMounted(false);
+ }
}
else
{
kdDebug(1219) << "HALBackend::setVolumeProperties : normal volume" << endl;
- medium->mountableState(
- libhal_volume_get_device_file(halVolume), /* Device node */
- TQString::fromUtf8(libhal_volume_get_mount_point(halVolume)), /* Mount point */
- libhal_volume_get_fstype(halVolume), /* Filesystem type */
- libhal_volume_is_mounted(halVolume) ); /* Mounted ? */
+ medium->setMountable(true);
+ medium->setDeviceNode(libhal_volume_get_device_file(halVolume));
+ medium->setMountPoint(TQString::fromUtf8(libhal_volume_get_mount_point(halVolume)));
+ medium->setFsType(libhal_volume_get_fstype(halVolume));
+ medium->setMounted(libhal_volume_is_mounted(halVolume));
}
@@ -570,7 +574,8 @@ void HALBackend::setVolumeProperties(Medium* medium)
if (libhal_volume_disc_is_blank(halVolume))
{
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
}
else
{
@@ -584,7 +589,8 @@ void HALBackend::setVolumeProperties(Medium* medium)
if (libhal_volume_disc_is_blank(halVolume))
{
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
}
else
{
@@ -609,7 +615,8 @@ void HALBackend::setVolumeProperties(Medium* medium)
if (libhal_volume_disc_has_audio(halVolume) && !libhal_volume_disc_has_data(halVolume))
{
mimeType = "media/audiocd";
- medium->unmountableState( "audiocd:/?device=" + TQString(libhal_volume_get_device_file(halVolume)) );
+ medium->setMountable(false);
+ medium->setBaseURL("audiocd:/?device=" + TQString(libhal_volume_get_device_file(halVolume)));
}
medium->setIconName(TQString::null);
@@ -653,12 +660,14 @@ void HALBackend::setVolumeProperties(Medium* medium)
case LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER:
{
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
+ medium->setMountable(false);
if (libhal_device_get_property_QString(m_halContext, driveUdi.latin1(), "info.product") == "iPod" &&
- KProtocolInfo::isKnownProtocol( TQString("ipod") ) )
+ KProtocolInfo::isKnownProtocol( TQString("ipod") ) )
{
- medium->unmountableState( "ipod:/" );
- medium->mountableState( libhal_volume_is_mounted(halVolume) );
+ medium->setBaseURL("ipod:/");
+ medium->setMountable(true);
+ medium->setMounted(libhal_volume_is_mounted(halVolume));
}
break;
}
@@ -723,11 +732,11 @@ bool HALBackend::setFstabProperties( Medium *medium )
if ( fstype.isNull() )
fstype = "auto";
- medium->mountableState(
- medium->deviceNode(),
- mp, /* Mount point */
- fstype, /* Filesystem type */
- mounted ); /* Mounted ? */
+ medium->setMountable(true);
+ medium->setDeviceNode(medium->deviceNode());
+ medium->setMountPoint(mp);
+ medium->setFsType(fstype);
+ medium->setMounted(mounted);
return true;
}
@@ -768,7 +777,11 @@ bool HALBackend::setFloppyProperties(Medium* medium)
medium->setLabel(i18n("Unknown Drive"));
// HAL hates floppies - so we have to do it twice ;(
- medium->mountableState(libhal_drive_get_device_file(halDrive), TQString::null, TQString::null, false);
+ medium->setMountable(true);
+ medium->setDeviceNode(libhal_drive_get_device_file(halDrive));
+ medium->setMountPoint(TQString::null);
+ medium->setFsType(TQString::null);
+ medium->setMounted(false);
setFloppyMountState(medium);
if (drive_type == "floppy")
@@ -813,7 +826,11 @@ void HALBackend::setFloppyMountState( Medium *medium )
{
fstype = (*it)->mountType().isNull() ? (*it)->mountType() : "auto";
mountpoint = (*it)->mountPoint();
- medium->mountableState( medium->deviceNode(), mountpoint, fstype, true );
+ medium->setMountable(true);
+ medium->setDeviceNode(medium->deviceNode());
+ medium->setMountPoint(mountpoint);
+ medium->setFsType(fstype);
+ medium->setMounted(true);
return;
}
}
@@ -847,7 +864,8 @@ void HALBackend::setCameraProperties(Medium* medium)
libhal_free_string(cam);
/** @todo find the rest of this URL */
- medium->unmountableState(device);
+ medium->setMountable(false);
+ medium->setBaseURL(device);
medium->setMimeType("media/gphoto2camera");
medium->setIconName(TQString::null);
if (libhal_device_property_exists(m_halContext, udi, "usb_device.product", NULL))
@@ -1605,7 +1623,6 @@ TQStringVariantMap HALBackend::mount(const Medium *medium)
return result;
}
- medium->setHalMounted(true);
ResetProperties(medium->id().latin1());
result["result"] = true;
@@ -1812,7 +1829,6 @@ TQStringVariantMap HALBackend::unmount(const TQString &id)
dbus_message_unref (reply);
}
- medium->setHalMounted(false);
ResetProperties(medium->id().latin1());
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp
index b06824d0c..dc0a108d6 100644
--- a/tdeioslave/media/mediamanager/medialist.cpp
+++ b/tdeioslave/media/mediamanager/medialist.cpp
@@ -128,42 +128,42 @@ bool MediaList::changeMediumState(const Medium &medium, bool allowNotification)
{
kdDebug(1219) << "MediaList::changeMediumState(const Medium &) for id " << medium.id() << endl;
- if ( !m_idMap.contains(medium.id()) ) return false;
+ if (!m_idMap.contains(medium.id())) return false;
Medium *m = m_idMap[medium.id()];
- if ( medium.isMountable() )
+ m->setMountable(medium.isMountable());
+ if (medium.isMountable())
{
- TQString device_node = medium.deviceNode();
- TQString clear_device_udi = medium.clearDeviceUdi();
- TQString mount_point = medium.mountPoint();
- TQString fs_type = medium.fsType();
- bool mounted = medium.isMounted();
-
- m->mountableState( device_node, clear_device_udi, mount_point, fs_type, mounted );
+ m->setMountable(true);
+ m->setDeviceNode(medium.deviceNode());
+ m->setClearDeviceUdi(medium.clearDeviceUdi());
+ m->setMountPoint(medium.mountPoint());
+ m->setFsType(medium.fsType());
+ m->setMounted(medium.isMounted());
}
else
{
- m->unmountableState( medium.baseURL() );
+ m->setBaseURL(medium.baseURL());
}
-
if (!medium.mimeType().isEmpty())
{
- m->setMimeType( medium.mimeType() );
+ m->setMimeType(medium.mimeType());
}
if (!medium.iconName().isEmpty())
{
- m->setIconName( medium.iconName() );
+ m->setIconName(medium.iconName());
}
if (!medium.label().isEmpty())
{
- m->setLabel( medium.label() );
+ m->setLabel(medium.label());
}
m->setHidden(medium.hidden());
+ m->setSoftHidden(medium.softHidden());
emit mediumStateChanged(m->id(), m->name(), !m->needMounting(), allowNotification);
return true;
@@ -184,7 +184,8 @@ bool MediaList::changeMediumState(const TQString &id,
Medium *medium = m_idMap[id];
- medium->unmountableState( baseURL );
+ medium->setMountable(false);
+ medium->setBaseURL(baseURL);
if (!mimeType.isEmpty())
{
@@ -225,7 +226,11 @@ bool MediaList::changeMediumState(const TQString &id,
Medium *medium = m_idMap[id];
- medium->mountableState( deviceNode, mountPoint, fsType, mounted );
+ medium->setMountable(true);
+ medium->setDeviceNode(deviceNode);
+ medium->setMountPoint(mountPoint);
+ medium->setFsType(fsType);
+ medium->setMounted(mounted);
if (!mimeType.isEmpty())
{
@@ -262,7 +267,12 @@ bool MediaList::changeMediumState(const TQString &id, bool mounted,
Medium *medium = m_idMap[id];
- if ( !medium->mountableState( mounted ) ) return false;
+ medium->setMountable(true);
+ medium->setMounted(mounted);
+ if (medium->deviceNode().isEmpty() || !medium->isMountable())
+ {
+ return false;
+ }
if (!mimeType.isEmpty())
{
diff --git a/tdeioslave/media/mediamanager/removablebackend.cpp b/tdeioslave/media/mediamanager/removablebackend.cpp
index 54df3d6f1..dacb9b704 100644
--- a/tdeioslave/media/mediamanager/removablebackend.cpp
+++ b/tdeioslave/media/mediamanager/removablebackend.cpp
@@ -63,8 +63,11 @@ bool RemovableBackend::plug(const TQString &devNode, const TQString &label)
if (!m_removableIds.contains(id))
{
Medium *medium = new Medium(id, id, name);
- medium->mountableState(devNode, TQString::null,
- TQString::null, false);
+ medium->setMountable(true);
+ medium->setDeviceNode(devNode);
+ medium->setMountPoint(TQString::null);
+ medium->setFsType(TQString::null);
+ medium->setMounted(false);
TQStringList words = TQStringList::split(" ", label);
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index 45c58081d..dc780d455 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -465,8 +465,11 @@ void TDEBackend::setVolumeProperties(Medium* medium)
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ medium->setMountable(true);
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
TQString diskLabel = sdevice->diskLabel();
bool useDefaultLabel = diskLabel.isNull();
@@ -515,7 +518,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cdrom" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-ROM");
}
}
@@ -524,7 +528,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-r" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-R");
}
}
@@ -533,7 +538,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank CD-RW");
}
}
@@ -542,7 +548,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Magneto-Optical CD");
}
}
@@ -551,7 +558,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW");
}
}
@@ -560,7 +568,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/cd-rw" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankcd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Mount Ranier CD-RW-W");
}
}
@@ -569,7 +578,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-ROM");
}
}
@@ -578,7 +588,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RAM");
}
}
@@ -587,7 +598,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-R");
}
}
@@ -596,7 +608,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD-RW");
}
}
@@ -605,7 +618,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-R");
}
}
@@ -614,7 +628,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD-RW");
}
}
@@ -623,7 +638,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+R");
}
}
@@ -632,7 +648,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank DVD+RW");
}
}
@@ -641,7 +658,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+R");
}
}
@@ -650,7 +668,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/dvd" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankdvd";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank Dual Layer DVD+RW");
}
}
@@ -659,7 +678,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-ROM");
}
}
@@ -668,7 +688,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-R");
}
}
@@ -677,7 +698,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank BLURAY-RW");
}
}
@@ -686,7 +708,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-ROM");
}
}
@@ -695,7 +718,8 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-R");
}
}
@@ -704,14 +728,16 @@ void TDEBackend::setVolumeProperties(Medium* medium)
mimeType = "media/bluray" + MOUNT_MEDIA_SUFFIX;
if (sdevice->checkDiskStatus(TDEDiskDeviceStatus::Blank)) {
mimeType = "media/blankbluray";
- medium->unmountableState("");
+ medium->setMountable(false);
+ medium->setBaseURL(TQString::null);
diskLabel = i18n("Blank HDDVD-RW");
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::CDAudio)) {
mimeType = "media/audiocd";
- medium->unmountableState("audiocd:/?device=" + sdevice->deviceNode());
+ medium->setMountable(false);
+ medium->setBaseURL("audiocd:/?device=" + sdevice->deviceNode());
diskLabel = i18n("Audio CD");
}
@@ -759,9 +785,11 @@ void TDEBackend::setVolumeProperties(Medium* medium)
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::MediaDevice)) {
medium->setIconName("ipod" + MOUNTED_ICON_SUFFIX);
- if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol( TQString("ipod") ) ) {
- medium->unmountableState( "ipod:/" );
- medium->mountableState(!sdevice->mountPath().isNull());
+ medium->setMountable(false);
+ if (sdevice->vendorModel().upper().contains("IPOD") && KProtocolInfo::isKnownProtocol(TQString("ipod"))) {
+ medium->setBaseURL("ipod:/");
+ medium->setMountable(true);
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Tape)) {
@@ -801,15 +829,22 @@ bool TDEBackend::setFloppyProperties(Medium* medium)
medium->setEncrypted(false);
}
- // USAGE: mountableState(Device node, Mount point, Filesystem type, Mounted ?)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ medium->setMountable(true);
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
}
if (sdevice->isDiskOfType(TDEDiskDeviceType::Floppy)) {
setFloppyMountState(medium);
// We don't use the routine above as floppy disks are extremely slow (we don't want them accessed at all during media listing)
- medium->mountableState(sdevice->deviceNode(), sdevice->mountPath(), sdevice->fileSystemName(), !sdevice->mountPath().isNull());
+ medium->setMountable(true);
+ medium->setDeviceNode(sdevice->deviceNode());
+ medium->setMountPoint(sdevice->mountPath());
+ medium->setFsType(sdevice->fileSystemName());
+ medium->setMounted(!sdevice->mountPath().isEmpty());
if (sdevice->mountPath().isNull()) {
medium->setMimeType("media/floppy_unmounted");
@@ -866,7 +901,8 @@ void TDEBackend::setCameraProperties(Medium* medium)
device.sprintf("camera://@[usb:%s,%s]/", devNode0.ascii(), devNode1.ascii());
}
- medium->unmountableState(device);
+ medium->setMountable(false);
+ medium->setBaseURL(device);
medium->setMimeType("media/gphoto2camera");
medium->setIconName(TQString::null);
@@ -890,7 +926,11 @@ void TDEBackend::setFloppyMountState( Medium *medium )
if ((*it)->mountedFrom() == medium->deviceNode() ) {
fstype = (*it)->mountType().isNull() ? (*it)->mountType() : "auto";
mountpoint = (*it)->mountPoint();
- medium->mountableState( medium->deviceNode(), mountpoint, fstype, true );
+ medium->setMountable(true);
+ medium->setDeviceNode(medium->deviceNode());
+ medium->setMountPoint(mountpoint);
+ medium->setFsType(fstype);
+ medium->setMounted(true);
return;
}
}