summaryrefslogtreecommitdiffstats
path: root/tdeioslave
diff options
context:
space:
mode:
authorFrancois Andriot <francois.andriot@free.fr>2013-11-16 01:57:47 +0100
committerSlávek Banko <slavek.banko@axis.cz>2013-11-16 02:12:44 +0100
commit990c3797c488210c6285b28ce16f164f457be840 (patch)
tree6596ed126d4a6cf0e735cf9aa9c82885a6b1c9c1 /tdeioslave
parent24b097d1d513a512cfc3e9370a2cc58298ba5d91 (diff)
downloadtdelibs-990c3797c488210c6285b28ce16f164f457be840.tar.gz
tdelibs-990c3797c488210c6285b28ce16f164f457be840.zip
Add support for udisks and udisks2 to mount/unmount removable drives
This resolves Bug 1708
Diffstat (limited to 'tdeioslave')
-rw-r--r--tdeioslave/file/file.cc88
1 files changed, 69 insertions, 19 deletions
diff --git a/tdeioslave/file/file.cc b/tdeioslave/file/file.cc
index 75b3b17a1..b13357fe6 100644
--- a/tdeioslave/file/file.cc
+++ b/tdeioslave/file/file.cc
@@ -1658,18 +1658,43 @@ void FileProtocol::unmount( const TQString& _point )
bool FileProtocol::pmount(const TQString &dev)
{
- TQString epath = getenv("PATH");
- TQString path = TQString::fromLatin1("/sbin:/bin");
- if (!epath.isEmpty())
- path += ":" + epath;
- TQString pmountProg = TDEGlobal::dirs()->findExe("pmount", path);
+ TQString mountProg;
+ TQCString buffer;
- if (pmountProg.isEmpty())
- return false;
+#ifdef WITH_UDISKS2
+ // Use 'udisksctl' (UDISKS2) if available
+ if (mountProg.isEmpty()) {
+ mountProg = TDEGlobal::dirs()->findExe("udisksctl");
+ if (!mountProg.isEmpty()) {
+ buffer.sprintf( "%s mount -b %s", TQFile::encodeName(mountProg).data(),
+ TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+#endif // WITH_UDISKS2
- TQCString buffer;
- buffer.sprintf( "%s %s", TQFile::encodeName(pmountProg).data(),
- TQFile::encodeName(TDEProcess::quote(dev)).data() );
+#ifdef WITH_UDISKS
+ // Use 'udisks' (UDISKS1) if available
+ if (mountProg.isEmpty()) {
+ mountProg = TDEGlobal::dirs()->findExe("udisks");
+ if (!mountProg.isEmpty()) {
+ buffer.sprintf( "%s --mount %s", TQFile::encodeName(mountProg).data(),
+ TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+#endif // WITH_UDISKS
+
+ // Use 'pmount', if available
+ if (mountProg.isEmpty()) {
+ mountProg = TDEGlobal::dirs()->findExe("pmount");
+ if (!mountProg.isEmpty()) {
+ buffer.sprintf( "%s %s", TQFile::encodeName(mountProg).data(),
+ TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+
+ if (mountProg.isEmpty()) {
+ return false;
+ }
int res = system( buffer.data() );
@@ -1700,18 +1725,43 @@ bool FileProtocol::pumount(const TQString &point)
if (dev.isEmpty()) return false;
if (dev.endsWith("/")) dev.truncate(dev.length()-1);
- TQString epath = getenv("PATH");
- TQString path = TQString::fromLatin1("/sbin:/bin");
- if (!epath.isEmpty())
- path += ":" + epath;
- TQString pumountProg = TDEGlobal::dirs()->findExe("pumount", path);
+ TQString umountProg;
+ TQCString buffer;
- if (pumountProg.isEmpty())
- return false;
+#ifdef WITH_UDISKS2
+ // Use 'udisksctl' (UDISKS2), if available
+ if (umountProg.isEmpty()) {
+ umountProg = TDEGlobal::dirs()->findExe("udisksctl");
+ if (!umountProg.isEmpty()) {
+ buffer.sprintf( "%s unmount -b %s", TQFile::encodeName(umountProg).data(),
+ TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+#endif // WITH_UDISKS2
- TQCString buffer;
- buffer.sprintf( "%s %s", TQFile::encodeName(pumountProg).data(),
+#ifdef WITH_UDISKS
+ // Use 'udisks' (UDISKS1), if available
+ if (umountProg.isEmpty()) {
+ umountProg = TDEGlobal::dirs()->findExe("udisks");
+ if (!umountProg.isEmpty()) {
+ buffer.sprintf( "%s --unmount %s", TQFile::encodeName(umountProg).data(),
TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+#endif // WITH_UDISKS
+
+ // Use 'pumount', if available
+ if (umountProg.isEmpty()) {
+ umountProg = TDEGlobal::dirs()->findExe("pumount");
+ if (!umountProg.isEmpty()) {
+ buffer.sprintf( "%s %s", TQFile::encodeName(umountProg).data(),
+ TQFile::encodeName(TDEProcess::quote(dev)).data() );
+ }
+ }
+
+ if (umountProg.isEmpty()) {
+ return false;
+ }
int res = system( buffer.data() );