summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-06-01 21:55:11 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2019-07-08 10:33:33 +0900
commite44487e1b855106ddf00ade92a25493e11589ca1 (patch)
treec19755d458f464a6440813b6a97d29404b59257a
parent7d2c7f0621177487fcc3953921788f7cafc509af (diff)
downloadtdebase-e44487e1b855106ddf00ade92a25493e11589ca1.tar.gz
tdebase-e44487e1b855106ddf00ade92a25493e11589ca1.zip
Improved media manager dcop interface for mount/unmount/decrypt/undecrypt methods by returning more information.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--tdeioslave/media/mediaimpl.cpp16
-rw-r--r--tdeioslave/media/mediamanager/fstabbackend.cpp38
-rw-r--r--tdeioslave/media/mediamanager/fstabbackend.h8
-rw-r--r--tdeioslave/media/mediamanager/halbackend.cpp189
-rw-r--r--tdeioslave/media/mediamanager/halbackend.h10
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.cpp163
-rw-r--r--tdeioslave/media/mediamanager/mediamanager.h9
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.cpp177
-rw-r--r--tdeioslave/media/mediamanager/tdehardwarebackend.h10
-rw-r--r--tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp74
10 files changed, 430 insertions, 264 deletions
diff --git a/tdeioslave/media/mediaimpl.cpp b/tdeioslave/media/mediaimpl.cpp
index 7b22a5d22..1d00bebf2 100644
--- a/tdeioslave/media/mediaimpl.cpp
+++ b/tdeioslave/media/mediaimpl.cpp
@@ -266,12 +266,16 @@ bool MediaImpl::ensureMediumMounted(Medium &medium)
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "mount", medium.id());
- if (reply.isValid())
- reply.get(m_lastErrorMessage);
- else
- m_lastErrorMessage = i18n("Internal Error");
- if (!m_lastErrorMessage.isEmpty())
- m_lastErrorCode = TDEIO::ERR_SLAVE_DEFINED;
+ TQStringVariantMap mountResult;
+ if (reply.isValid()) {
+ reply.get(mountResult);
+ }
+ if (!mountResult.contains("result") || !mountResult["result"].toBool()) {
+ m_lastErrorMessage = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
+ }
+ if (!m_lastErrorMessage.isEmpty()) {
+ m_lastErrorCode = TDEIO::ERR_SLAVE_DEFINED;
+ }
else {
tqApp->eventLoop()->enterLoop();
}
diff --git a/tdeioslave/media/mediamanager/fstabbackend.cpp b/tdeioslave/media/mediamanager/fstabbackend.cpp
index 84910352d..c0e91c228 100644
--- a/tdeioslave/media/mediamanager/fstabbackend.cpp
+++ b/tdeioslave/media/mediamanager/fstabbackend.cpp
@@ -97,24 +97,34 @@ FstabBackend::~FstabBackend()
KDirWatch::self()->removeFile(MTAB);
}
-TQString FstabBackend::mount( const TQString &_udi )
+TQStringVariantMap FstabBackend::mount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
- if (!medium)
- return i18n("No such medium: %1").arg(_udi);
- TDEIO::Job* job = TDEIO::mount( false, 0, medium->deviceNode(), medium->mountPoint());
- TDEIO::NetAccess::synchronousRun( job, 0 );
- return TQString::null;
+ TQStringVariantMap result;
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ TDEIO::Job *job = TDEIO::mount(false, 0, medium->deviceNode(), medium->mountPoint());
+ TDEIO::NetAccess::synchronousRun(job, 0);
+ result["result"] = true;
+ return result;
}
-TQString FstabBackend::unmount( const TQString &_udi )
+TQStringVariantMap FstabBackend::unmount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
- if (!medium)
- return i18n("No such medium: %1").arg(_udi);
- TDEIO::Job* job = TDEIO::unmount( medium->mountPoint(), false);
- TDEIO::NetAccess::synchronousRun( job, 0 );
- return TQString::null;
+ TQStringVariantMap result;
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ TDEIO::Job *job = TDEIO::unmount(medium->mountPoint(), false);
+ TDEIO::NetAccess::synchronousRun(job, 0);
+ result["result"] = true;
+ return result;
}
void FstabBackend::slotDirty(const TQString &path)
diff --git a/tdeioslave/media/mediamanager/fstabbackend.h b/tdeioslave/media/mediamanager/fstabbackend.h
index e43ed48c0..24529d95a 100644
--- a/tdeioslave/media/mediamanager/fstabbackend.h
+++ b/tdeioslave/media/mediamanager/fstabbackend.h
@@ -1,5 +1,5 @@
/* This file is part of the KDE Project
- Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
+ Copyright (c) 2004 Kévin Ottens <ervin ipsquad net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -23,7 +23,7 @@
#include <tqobject.h>
#include <tqstringlist.h>
-#include <tqmap.h>
+#include <tqvariant.h>
#ifdef Q_OS_FREEBSD
#include <tqtimer.h>
@@ -42,8 +42,8 @@ public:
TQString &mimeType, TQString &iconName,
TQString &label);
- TQString mount(const TQString &id);
- TQString unmount(const TQString &id);
+ TQStringVariantMap mount(const TQString &id);
+ TQStringVariantMap unmount(const TQString &id);
private slots:
void slotDirty(const TQString &path);
diff --git a/tdeioslave/media/mediamanager/halbackend.cpp b/tdeioslave/media/mediamanager/halbackend.cpp
index 637b16bf0..071752d5a 100644
--- a/tdeioslave/media/mediamanager/halbackend.cpp
+++ b/tdeioslave/media/mediamanager/halbackend.cpp
@@ -1449,10 +1449,13 @@ TQString HALBackend::isInFstab(const Medium *medium)
return TQString::null;
}
-TQString HALBackend::mount(const Medium *medium)
+TQStringVariantMap HALBackend::mount(const Medium *medium)
{
- if (medium->isMounted())
- return TQString(); // that was easy
+ TQStringVariantMap result;
+ if (medium->isMounted()) {
+ result["result"] = true;
+ return result;
+ }
TQString mountPoint = isInFstab(medium);
if (!mountPoint.isNull())
@@ -1463,24 +1466,27 @@ TQString HALBackend::mount(const Medium *medium)
kdDebug() << "triggering user mount " << medium->deviceNode() << " " << mountPoint << " " << medium->id() << endl;
TDEIO::Job *job = TDEIO::mount( false, 0, medium->deviceNode(), mountPoint );
- connect(job, TQT_SIGNAL( result (TDEIO::Job *)),
- TQT_SLOT( slotResult( TDEIO::Job *)));
+ connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be mounted when the function
// completes. Thus block until the job completes.
while (!data.completed) {
kapp->eventLoop()->enterLoop();
}
- // Return the error message (if any) to the caller
- return (data.error) ? data.errorMessage : TQString::null;
-
- } else if (medium->id().startsWith("/org/kde/") )
- return i18n("Permission denied");
-
- TQStringList soptions;
+ if (!data.error) {
+ result["result"] = true;
+ return result;
+ }
+ else {
+ result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
+ result["result"] = false;
+ return result;
+ }
+ }
kdDebug() << "mounting " << medium->id() << "..." << endl;
+ TQStringList soptions;
TQMap<TQString,TQString> valids = MediaManagerUtils::splitOptions(mountoptions(medium->id()));
if (valids["flush"] == "true")
soptions << "flush";
@@ -1508,7 +1514,6 @@ TQString HALBackend::mount(const Medium *medium)
if (medium->fsType() == "ntfs") {
TQString fsLocale("locale=");
fsLocale += setlocale(LC_ALL, "");
-
soptions << fsLocale;
}
@@ -1549,7 +1554,6 @@ TQString HALBackend::mount(const Medium *medium)
}
}
-
const char **options = new const char*[soptions.size() + 1];
uint noptions = 0;
for (TQStringList::ConstIterator it = soptions.begin(); it != soptions.end(); ++it, ++noptions)
@@ -1559,13 +1563,13 @@ TQString HALBackend::mount(const Medium *medium)
}
options[noptions] = NULL;
- TQString qerror = i18n("Cannot mount encrypted drives!");
-
+ TQString qerror;
if (!medium->isEncrypted()) {
// normal volume
qerror = mount_priv(medium->id().latin1(), mount_point.utf8(), options, noptions, dbus_connection);
} else {
// see if we have a clear volume
+ error = i18n("Cannot mount encrypted drives!");
LibHalVolume* halVolume = libhal_volume_from_udi(m_halContext, medium->id().latin1());
if (halVolume) {
char* clearUdi = libhal_volume_crypto_get_clear_volume_udi(m_halContext, halVolume);
@@ -1579,45 +1583,59 @@ TQString HALBackend::mount(const Medium *medium)
if (!qerror.isEmpty()) {
kdError() << "mounting " << medium->id() << " returned " << qerror << endl;
- return qerror;
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
medium->setHalMounted(true);
ResetProperties(medium->id().latin1());
- return TQString();
+ result["result"] = true;
+ return result;
}
-TQString HALBackend::mount(const TQString &_udi)
+TQStringVariantMap HALBackend::mount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
- if (!medium)
- return i18n("No such medium: %1").arg(_udi);
-
- return mount(medium);
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ TQStringVariantMap result;
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+ return mount(medium);
}
-TQString HALBackend::unmount(const TQString &_udi)
+TQStringVariantMap HALBackend::unmount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
+ TQStringVariantMap result;
+
+ const Medium* medium = m_mediaList.findById(id);
if (!medium)
- { // now we get fancy: if the udi is no volume, it _might_ be a device with only one
+ {
+ // now we get fancy: if the udi is no volume, it _might_ be a device with only one
// volume on it (think CDs) - so we're so nice to the caller to unmount that volume
- LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, _udi.latin1());
+ LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, id.latin1());
if (halDrive)
{
int numVolumes;
char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, &numVolumes);
if (numVolumes == 1)
- medium = m_mediaList.findById( volumes[0] );
+ medium = m_mediaList.findById(volumes[0]);
}
}
- if ( !medium )
- return i18n("No such medium: %1").arg(_udi);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
if (!medium->isMounted())
- return TQString(); // that was easy
+ result["result"] = true;
+ return result;
+ }
TQString mountPoint = isInFstab(medium);
if (!mountPoint.isNull())
@@ -1628,16 +1646,22 @@ TQString HALBackend::unmount(const TQString &_udi)
kdDebug() << "triggering user unmount " << medium->deviceNode() << " " << mountPoint << endl;
TDEIO::Job *job = TDEIO::unmount( medium->mountPoint(), false );
- connect(job, TQT_SIGNAL( result (TDEIO::Job *)),
- TQT_SLOT( slotResult( TDEIO::Job *)));
+ connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be unmounted when the function
// completes. Thus block until the job completes.
while (!data.completed) {
kapp->eventLoop()->enterLoop();
}
- // Return the error message (if any) to the caller
- return (data.error) ? data.errorMessage : TQString::null;
+ if (!data.error) {
+ result["result"] = true;
+ return result;
+ }
+ else {
+ result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
+ result["result"] = false;
+ return result;
+ }
}
DBusMessage *dmesg, *reply;
@@ -1660,7 +1684,9 @@ TQString HALBackend::unmount(const TQString &_udi)
}
if (udi.isNull()) {
kdDebug() << "unmount failed: no udi" << endl;
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
kdDebug() << "unmounting " << udi << "..." << endl;
@@ -1670,14 +1696,18 @@ TQString HALBackend::unmount(const TQString &_udi)
if (dbus_error_is_set(&error))
{
dbus_error_free(&error);
- return TQString();
+ result["errStr"] = i18n("Unknown error");
+ result["result"] = false;
+ return result;
}
if (!(dmesg = dbus_message_new_method_call ("org.freedesktop.Hal", udi.latin1(),
"org.freedesktop.Hal.Device.Volume",
"Unmount"))) {
kdDebug() << "unmount failed for " << udi << ": could not create dbus message\n";
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
options[0] = "force";
@@ -1688,7 +1718,9 @@ TQString HALBackend::unmount(const TQString &_udi)
{
kdDebug() << "unmount failed for " << udi << ": could not append args to dbus message\n";
dbus_message_unref (dmesg);
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
char thisunmounthasfailed = 0;
@@ -1704,14 +1736,14 @@ TQString HALBackend::unmount(const TQString &_udi)
if (qerror.isEmpty()) {
dbus_message_unref(dmesg);
dbus_error_free(&error);
- return TQString();
+ result["result"] = true;
+ return result;
}
// @todo handle unmount error message
}
kdDebug() << "unmount failed for " << udi << ": " << error.name << " " << error.message << endl;
- qerror = "<qt>";
qerror += "<p>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and "
"currently mounted at <b>%4</b> could not be unmounted. ").arg(
"system:/media/" + medium->name(),
@@ -1750,7 +1782,9 @@ TQString HALBackend::unmount(const TQString &_udi)
if (thisunmounthasfailed != 0) {
dbus_message_unref (dmesg);
dbus_error_free (&error);
- return qerror;
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
}
@@ -1766,17 +1800,25 @@ TQString HALBackend::unmount(const TQString &_udi)
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- return TQString();
+ result["result"] = true;
+ return result;
}
-TQString HALBackend::decrypt(const TQString &_udi, const TQString &password)
+TQStringVariantMap HALBackend::decrypt(const TQString &id, const TQString &password)
{
- const Medium* medium = m_mediaList.findById(_udi);
- if (!medium)
- return i18n("No such medium: %1").arg(_udi);
+ TQStringVariantMap result;
+
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull())
- return TQString();
+ result["result"] = true;
+ return result;
+ }
const char *udi = medium->id().latin1();
DBusMessage *msg = NULL;
@@ -1790,7 +1832,9 @@ TQString HALBackend::decrypt(const TQString &_udi, const TQString &password)
"Setup");
if (msg == NULL) {
kdDebug() << "decrypt failed for " << udi << ": could not create dbus message\n";
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
TQCString pwdUtf8 = password.utf8();
@@ -1798,7 +1842,9 @@ TQString HALBackend::decrypt(const TQString &_udi, const TQString &password)
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &pwd_utf8, DBUS_TYPE_INVALID)) {
kdDebug() << "decrypt failed for " << udi << ": could not append args to dbus message\n";
dbus_message_unref (msg);
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
dbus_error_init (&error);
@@ -1813,7 +1859,9 @@ TQString HALBackend::decrypt(const TQString &_udi, const TQString &password)
dbus_error_free (&error);
dbus_message_unref (msg);
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- return qerror;
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
dbus_message_unref (msg);
@@ -1821,17 +1869,25 @@ TQString HALBackend::decrypt(const TQString &_udi, const TQString &password)
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- return TQString();
+ result["result"] = true;
+ return result;
}
-TQString HALBackend::undecrypt(const TQString &_udi)
+TQStringVariantMap HALBackend::undecrypt(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
- if (!medium)
- return i18n("No such medium: %1").arg(_udi);
+ TQStringVariantMap result;
- if (!medium->isEncrypted() || medium->clearDeviceUdi().isNull())
- return TQString();
+ const Medium *medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
+ }
+
+ if (!medium->isEncrypted() || !medium->clearDeviceUdi().isNull())
+ result["result"] = true;
+ return result;
+ }
const char *udi = medium->id().latin1();
DBusMessage *msg = NULL;
@@ -1845,13 +1901,17 @@ TQString HALBackend::undecrypt(const TQString &_udi)
"Teardown");
if (msg == NULL) {
kdDebug() << "teardown failed for " << udi << ": could not create dbus message\n";
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
if (!dbus_message_append_args (msg, DBUS_TYPE_INVALID)) {
kdDebug() << "teardown failed for " << udi << ": could not append args to dbus message\n";
dbus_message_unref (msg);
- return i18n("Internal Error");
+ result["errStr"] = i18n("Internal error");
+ result["result"] = false;
+ return result;
}
dbus_error_init (&error);
@@ -1863,7 +1923,9 @@ TQString HALBackend::undecrypt(const TQString &_udi)
dbus_error_free (&error);
dbus_message_unref (msg);
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- return qerror;
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
dbus_message_unref (msg);
@@ -1873,7 +1935,8 @@ TQString HALBackend::undecrypt(const TQString &_udi)
while (dbus_connection_dispatch(dbus_connection) == DBUS_DISPATCH_DATA_REMAINS) ;
- return TQString();
+ result["result"] = true;
+ return result;
}
#include "halbackend.moc"
diff --git a/tdeioslave/media/mediamanager/halbackend.h b/tdeioslave/media/mediamanager/halbackend.h
index 8dde45580..e799ad6e0 100644
--- a/tdeioslave/media/mediamanager/halbackend.h
+++ b/tdeioslave/media/mediamanager/halbackend.h
@@ -83,11 +83,11 @@ public:
bool setMountoptions(const TQString &id, const TQStringList &options);
- TQString mount(const TQString &id);
- TQString mount(const Medium *medium);
- TQString unmount(const TQString &id);
- TQString decrypt(const TQString &id, const TQString &password);
- TQString undecrypt(const TQString &id);
+ TQStringVariantMap mount(const TQString &id);
+ TQStringVariantMap mount(const Medium *medium);
+ TQStringVariantMap unmount(const TQString &id);
+ TQStringVariantMap decrypt(const TQString &id, const TQString &password);
+ TQStringVariantMap undecrypt(const TQString &id);
private:
/**
diff --git a/tdeioslave/media/mediamanager/mediamanager.cpp b/tdeioslave/media/mediamanager/mediamanager.cpp
index b08c37794..ef6721999 100644
--- a/tdeioslave/media/mediamanager/mediamanager.cpp
+++ b/tdeioslave/media/mediamanager/mediamanager.cpp
@@ -240,76 +240,119 @@ bool MediaManager::setMountoptions(const TQString &name, const TQStringList &opt
#endif // COMPILE_HALBACKEND
}
-TQString MediaManager::mount(const TQString &name)
+TQStringVariantMap MediaManager::mount(const TQString &uid)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return i18n("Feature only available with HAL");
- return m_halbackend->mount(name);
-#else // COMPILE_HALBACKEND
- #ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return i18n("Feature only available with the TDE hardware backend");
- return m_tdebackend->mount(name);
- #else // COMPILE_TDEHARDWAREBACKEND
- if ( !m_fstabbackend ) // lying :)
- return i18n("Feature only available with HAL or TDE hardware backend");
- return m_fstabbackend->mount( name );
- #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ TQStringVariantMap result;
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (!m_tdebackend) {
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_tdebackend->mount(uid);
+#elif defined COMPILE_HALBACKEND
+ if (!m_halbackend) {
+ result["errStr"] = i18n("Feature only available with HAL");
+ result["result"] = false;
+ return result;
+ }
+ return m_halbackend->mount(uid);
+#else
+ if (!m_fstabbackend) {
+ result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_fstabbackend->mount(uid);
+#endif
}
-TQString MediaManager::unmount(const TQString &name)
+TQStringVariantMap MediaManager::unmount(const TQString &uid)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return i18n("Feature only available with HAL");
- return m_halbackend->unmount(name);
-#else // COMPILE_HALBACKEND
- #ifdef COMPILE_TDEHARDWAREBACKEND
- if (!m_tdebackend)
- return i18n("Feature only available with HAL or TDE hardware backend");
- return m_tdebackend->unmount(name);
- #else // COMPILE_TDEHARDWAREBACKEND
- if ( !m_fstabbackend ) // lying :)
- return i18n("Feature only available with HAL or TDE hardware backend");
- return m_fstabbackend->unmount( name );
- #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ TQStringVariantMap result;
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (!m_tdebackend) {
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_tdebackend->unmount(uid);
+#elif defined COMPILE_HALBACKEND
+ if (!m_halbackend) {
+ result["errStr"] = i18n("Feature only available with HAL");
+ result["result"] = false;
+ return result;
+ }
+ return m_halbackend->unmount(uid);
+#else
+ if (!m_fstabbackend) {
+ result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_fstabbackend->unmount(uid);
+#endif
}
-TQString MediaManager::decrypt(const TQString &name, const TQString &password)
+TQStringVariantMap MediaManager::decrypt(const TQString &uid, const TQString &password)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return i18n("Feature only available with HAL");
- return m_halbackend->decrypt(name, password);
-#else // COMPILE_HALBACKEND
-// #ifdef COMPILE_TDEHARDWAREBACKEND
-// if (!m_tdebackend)
-// return i18n("Feature only available with HAL or TDE hardware backend");
-// return m_tdebackend->decrypt(name, password);
-// #else // COMPILE_TDEHARDWAREBACKEND
- return i18n("Feature only available with HAL");
-// #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ TQStringVariantMap result;
+/*
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (!m_tdebackend) {
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_tdebackend->decrypt(uid, password);
+#elif defined COMPILE_HALBACKEND
+*/
+#if defined COMPILE_HALBACKEND
+ if (!m_halbackend) {
+ result["errStr"] = i18n("Feature only available with HAL");
+ result["result"] = false;
+ return result;
+ }
+ return m_halbackend->decrypt(uid, password);
+
+#else
+// if (!m_fstabbackend) {
+ result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
+ result["result"] = false;
+ return result;
+// }
+// return m_fstabbackend->decrypt(uid, password);
+#endif
}
-TQString MediaManager::undecrypt(const TQString &name)
+TQStringVariantMap MediaManager::undecrypt(const TQString &uid)
{
-#ifdef COMPILE_HALBACKEND
- if (!m_halbackend)
- return i18n("Feature only available with HAL");
- return m_halbackend->undecrypt(name);
-#else // COMPILE_HALBACKEND
-// #ifdef COMPILE_TDEHARDWAREBACKEND
-// if (!m_tdebackend)
-// return i18n("Feature only available with HAL or TDE hardware backend");
-// return m_tdebackend->undecrypt(name);
-// #else // COMPILE_TDEHARDWAREBACKEND
- return i18n("Feature only available with HAL");
-// #endif // COMPILE_TDEHARDWAREBACKEND
-#endif // COMPILE_HALBACKEND
+ TQStringVariantMap result;
+/*
+#ifdef COMPILE_TDEHARDWAREBACKEND
+ if (!m_tdebackend) {
+ result["errStr"] = i18n("Feature only available with the TDE hardware backend");
+ result["result"] = false;
+ return result;
+ }
+ return m_tdebackend->undecrypt(uid);
+#elif defined COMPILE_HALBACKEND
+*/
+#if defined COMPILE_HALBACKEND
+ if (!m_halbackend) {
+ result["errStr"] = i18n("Feature only available with HAL");
+ result["result"] = false;
+ return result;
+ }
+ return m_halbackend->undecrypt(uid);
+#else
+// if (!m_fstabbackend) {
+ result["errStr"] = i18n("Feature only available with HAL or TDE hardware backend");
+ result["result"] = false;
+ return result;
+// }
+// return m_fstabbackend->undecrypt(uid);
+#endif
}
TQString MediaManager::nameForLabel(const TQString &label)
diff --git a/tdeioslave/media/mediamanager/mediamanager.h b/tdeioslave/media/mediamanager/mediamanager.h
index 256d11bf8..673629cf9 100644
--- a/tdeioslave/media/mediamanager/mediamanager.h
+++ b/tdeioslave/media/mediamanager/mediamanager.h
@@ -22,6 +22,7 @@
#include <kdedmodule.h>
#include <tqstring.h>
#include <tqstringlist.h>
+#include <tqvariant.h>
#include "medialist.h"
#include "backendbase.h"
@@ -46,10 +47,10 @@ k_dcop:
TQStringList mountoptions(const TQString &name);
bool setMountoptions(const TQString &name, const TQStringList &options);
- TQString mount(const TQString &uid);
- TQString unmount(const TQString &uid);
- TQString decrypt(const TQString &uid, const TQString &password);
- TQString undecrypt(const TQString &uid);
+ TQStringVariantMap mount(const TQString &uid);
+ TQStringVariantMap unmount(const TQString &uid);
+ TQStringVariantMap decrypt(const TQString &uid, const TQString &password);
+ TQStringVariantMap undecrypt(const TQString &uid);
TQString nameForLabel(const TQString &label);
ASYNC setUserLabel(const TQString &name, const TQString &label);
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
index 33d1fe455..c228caf71 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp
@@ -50,15 +50,6 @@
(medium->isEncrypted() ? (sdevice->isDiskOfType(TDEDiskDeviceType::UnlockedCrypt) ? "-decrypted" : "-encrypted") : "" ) \
)
-#define CHECK_FOR_AND_EXECUTE_AUTOMOUNT(udi, medium, allowNotification) { \
- TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(udi)); \
- kdDebug(1219) << "automount " << options["automount"] << endl; \
- if (options["automount"] == "true" && allowNotification ) { \
- TQString error = mount(medium); \
- if (!error.isEmpty()) \
- kdDebug(1219) << "error " << error << endl; \
- } \
- }
/* Constructor */
TDEBackend::TDEBackend(MediaList &list, TQObject* parent)
@@ -208,7 +199,15 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
kdDebug(1219) << "TDEBackend::AddDevice inserted hard medium for " << sdevice->uniqueID() << endl;
// Automount if enabled
- CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification)
+ TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(sdevice->uniqueID()));
+ kdDebug(1219) << "automount " << options["automount"] << endl;
+ if (options["automount"] == "true" && allowNotification ) {
+ TQStringVariantMap mountResult = mount(medium);
+ if (!mountResult["result"].toBool()) {
+ TQString error = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
+ kdDebug(1219) << "error " << error << endl;
+ }
+ }
}
}
@@ -251,7 +250,15 @@ void TDEBackend::AddDevice(TDEStorageDevice * sdevice, bool allowNotification)
kdDebug(1219) << "TDEBackend::AddDevice inserted optical medium for " << sdevice->uniqueID() << endl;
// Automount if enabled
- CHECK_FOR_AND_EXECUTE_AUTOMOUNT(sdevice->uniqueID(), medium, allowNotification)
+ TQMap<TQString,TQString> options = MediaManagerUtils::splitOptions(mountoptions(sdevice->uniqueID()));
+ kdDebug(1219) << "automount " << options["automount"] << endl;
+ if (options["automount"] == "true" && allowNotification ) {
+ TQStringVariantMap mountResult = mount(medium);
+ if (!mountResult["result"].toBool()) {
+ TQString error = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
+ kdDebug(1219) << "error " << error << endl;
+ }
+ }
}
// Floppy & zip drives
@@ -1179,49 +1186,55 @@ void TDEBackend::slotPasswordCancel() {
m_decryptPasswordValid = true;
}
-TQString TDEBackend::mount(const Medium *medium)
+TQStringVariantMap TDEBackend::mount(const Medium *medium)
{
+ TQStringVariantMap result;
if (medium->isMounted()) {
- return TQString(); // that was easy
+ result["result"] = true;
+ return result;
}
TQString mountPoint = isInFstab(medium);
- if (!mountPoint.isNull())
+ if (!mountPoint.isEmpty())
{
struct mount_job_data data;
data.completed = false;
data.medium = medium;
- TDEIO::Job *job = TDEIO::mount( false, 0, medium->deviceNode(), mountPoint );
- connect(job, TQT_SIGNAL( result (TDEIO::Job *)), TQT_SLOT( slotResult( TDEIO::Job *)));
+ TDEIO::Job *job = TDEIO::mount(false, 0, medium->deviceNode(), mountPoint);
+ connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be mounted when the function
// completes. Thus block until the job completes.
while (!data.completed) {
kapp->eventLoop()->enterLoop();
}
- // Return the error message (if any) to the caller
- return (data.error) ? data.errorMessage : TQString::null;
-
+ if (!data.error) {
+ result["result"] = true;
+ return result;
+ }
+ else {
+ result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
+ result["result"] = false;
+ return result;
+ }
}
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
-
- TDEStorageDevice * sdevice = hwdevices->findDiskByUID(medium->id());
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- return i18n("Internal error");
+ result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["result"] = false;
+ return result;
}
- TQString diskLabel;
-
TQMap<TQString,TQString> valids = MediaManagerUtils::splitOptions(mountoptions(medium->id()));
-
+ TQString diskLabel;
TQString mount_point = valids["mountpoint"];
if (mount_point.startsWith("/media/")) {
diskLabel = mount_point.mid(7);
}
-
- if (diskLabel == "") {
+ if (diskLabel.isEmpty()) {
// Try to use a pretty mount point if possible
TQStringList pieces = TQStringList::split("/", sdevice->deviceNode(), FALSE);
TQString node = pieces[pieces.count()-1];
@@ -1229,22 +1242,17 @@ TQString TDEBackend::mount(const Medium *medium)
diskLabel.replace("/", "_");
}
- TQString qerror = i18n("Cannot mount encrypted drives!");
-
+ TQString qerror;
if (!medium->isEncrypted()) {
// normal volume
TQStringVariantMap mountResult = sdevice->mountDevice(diskLabel, valids);
TQString mountedPath = mountResult.contains("mountPath") ? mountResult["mountPath"].toString() : TQString::null;
if (mountedPath.isEmpty()) {
- qerror = i18n("<qt>Unable to mount this device.<p>Potential reasons include:<br>Improper device and/or user privilege level<br>Corrupt data on storage device");
+ qerror = i18n("Unable to mount this device.");
TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
- qerror.append("</qt>");
- }
- else {
- qerror = "";
}
}
else {
@@ -1275,7 +1283,9 @@ TQString TDEBackend::mount(const Medium *medium)
if (m_decryptionPassword.isNull()) {
delete m_decryptDialog;
- return TQString("Decryption aborted");
+ result["errStr"] = i18n("Decryption aborted");
+ result["result"] = false;
+ return result;
}
else {
// Just for some added fun, if udev emits a medium change event, which I then forward, with mounted==0, it stops the MediaProtocol::listDir method dead in its tracks,
@@ -1311,17 +1321,16 @@ TQString TDEBackend::mount(const Medium *medium)
continue_trying_to_decrypt = true;
}
else {
- qerror = i18n("<qt>Unable to mount this device.<p>Potential reasons include:<br>Improper device and/or user privilege level<br>Corrupt data on storage device<br>Incorrect encryption password");
+ qerror = i18n("Cannot mount encrypted drives!");
+ qerror = i18n("Unable to mount this device.");
TQString errStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : TQString::null;
if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
- qerror.append("</qt>");
continue_trying_to_decrypt = false;
}
}
else {
- qerror = "";
continue_trying_to_decrypt = false;
}
@@ -1331,7 +1340,9 @@ TQString TDEBackend::mount(const Medium *medium)
}
if (!qerror.isEmpty()) {
- return qerror;
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
ResetProperties(sdevice, false, true);
@@ -1340,29 +1351,36 @@ TQString TDEBackend::mount(const Medium *medium)
m_ignoreDeviceChangeEvents.remove(sdevice->uniqueID());
}
- return TQString();
+ result["result"] = true;
+ return result;
}
-TQString TDEBackend::mount(const TQString &_udi)
+TQStringVariantMap TDEBackend::mount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
+ const Medium *medium = m_mediaList.findById(id);
if (!medium) {
- return i18n("No such medium: %1").arg(_udi);
+ TQStringVariantMap result;
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
}
-
return mount(medium);
}
-TQString TDEBackend::unmount(const TQString &_udi)
+TQStringVariantMap TDEBackend::unmount(const TQString &id)
{
- const Medium* medium = m_mediaList.findById(_udi);
+ TQStringVariantMap result;
- if ( !medium ) {
- return i18n("No such medium: %1").arg(_udi);
+ const Medium* medium = m_mediaList.findById(id);
+ if (!medium) {
+ result["errStr"] = i18n("No such medium: %1").arg(id);
+ result["result"] = false;
+ return result;
}
if (!medium->isMounted()) {
- return TQString(); // that was easy
+ result["result"] = true;
+ return result;
}
TQString mountPoint = isInFstab(medium);
@@ -1373,83 +1391,90 @@ TQString TDEBackend::unmount(const TQString &_udi)
data.medium = medium;
TDEIO::Job *job = TDEIO::unmount( medium->mountPoint(), false );
- connect(job, TQT_SIGNAL( result (TDEIO::Job *)), TQT_SLOT( slotResult( TDEIO::Job *)));
+ connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
mount_jobs[job] = &data;
// The caller expects the device to be unmounted when the function
// completes. Thus block until the job completes.
while (!data.completed) {
kapp->eventLoop()->enterLoop();
}
- // Return the error message (if any) to the caller
- return (data.error) ? data.errorMessage : TQString::null;
+ if (!data.error) {
+ result["result"] = true;
+ return result;
+ }
+ else {
+ result["errStr"] = data.errorMessage; // Return the error message (if any) to the caller
+ result["result"] = false;
+ return result;
+ }
}
- TQString udi = TQString::null;
-
TDEHardwareDevices *hwdevices = TDEGlobal::hardwareDevices();
-
- TDEStorageDevice * sdevice = hwdevices->findDiskByUID(medium->id());
+ TDEStorageDevice *sdevice = hwdevices->findDiskByUID(medium->id());
if (!sdevice) {
- return i18n("Internal error");
+ result["errStr"] = i18n("Internal error. Couldn't find medium.");
+ result["result"] = false;
+ return result;
}
- TQString qerror;
- TQString origqerror;
-
// Save these for later
TQString uid = sdevice->uniqueID();
TQString node = sdevice->deviceNode();
+ TQString qerror;
TQStringVariantMap unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
+ qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ "<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
+ medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
- qerror.append("</qt>");
- }
- else {
- qerror = "";
}
if (unmountResult.contains("retCode") && unmountResult["retCode"].toInt() == 1280) {
// Failed as BUSY
TQString processesUsingDev = listUsingProcesses(medium);
if (!processesUsingDev.isNull()) {
- if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" + medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL()).arg(processesUsingDev)) == KMessageBox::Yes) {
+ if (KMessageBox::warningYesNo(0, i18n("<qt>The device <b>%1</b> (%2) named <b>'%3'</b> and currently "
+ "mounted at <b>%4</b> can not be unmounted at this time.<p>%5<p><b>Would you like to forcibly "
+ "terminate these processes?</b><br><i>All unsaved data would be lost</i>").arg("system:/media/" +
+ medium->name()).arg(medium->deviceNode()).arg(medium->prettyLabel()).arg(medium->prettyBaseURL().pathOrURL())
+ .arg(processesUsingDev)) == KMessageBox::Yes) {
killUsingProcesses(medium);
unmountResult = sdevice->unmountDevice();
if (unmountResult["result"].toBool() == false) {
// Unmount failed!
- qerror = "<qt>" + i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at <b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(), medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
+ qerror = i18n("Unfortunately, the device <b>%1</b> (%2) named <b>'%3'</b> and currently mounted at "
+ "<b>%4</b> could not be unmounted. ").arg("system:/media/" + medium->name(), medium->deviceNode(),
+ medium->prettyLabel(), medium->prettyBaseURL().pathOrURL());
TQString errStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : TQString::null;
if (!errStr.isEmpty()) {
qerror.append(i18n("<p>Technical details:<br>").append(errStr));
}
- qerror.append("</qt>");
- }
- else {
- qerror = "";
}
}
}
}
- if (qerror != "") {
- return qerror;
+ if (!qerror.isEmpty()) {
+ result["errStr"] = qerror;
+ result["result"] = false;
+ return result;
}
- // There is a possibility that the storage device was unceremoniously removed from the system immediately after it was unmounted
- // There is no reliable way to know if this happened either!
+ // There is a possibility that the storage device was unceremoniously removed from the system immediately
+ // after it was unmounted. There is no reliable way to know if this happened either!
// For now, see if the device node still exists
TQFileInfo checkDN(node);
if (!checkDN.exists()) {
m_mediaList.removeMedium(uid, true);
}
- return TQString();
+ result["result"] = true;
+ return result;
}
void TDEBackend::slotResult(TDEIO::Job *job)
diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.h b/tdeioslave/media/mediamanager/tdehardwarebackend.h
index 19f697a84..bc9bcca4a 100644
--- a/tdeioslave/media/mediamanager/tdehardwarebackend.h
+++ b/tdeioslave/media/mediamanager/tdehardwarebackend.h
@@ -68,11 +68,11 @@ public:
bool setMountoptions(const TQString &id, const TQStringList &options);
- TQString mount(const TQString &id);
- TQString mount(const Medium *medium);
- TQString unmount(const TQString &id);
-// TQString decrypt(const TQString &id, const TQString &password);
-// TQString undecrypt(const TQString &id);
+ TQStringVariantMap mount(const TQString &id);
+ TQStringVariantMap mount(const Medium *medium);
+ TQStringVariantMap unmount(const TQString &id);
+// TQStringVariantMap decrypt(const TQString &id, const TQString &password);
+// TQStringVariantMap undecrypt(const TQString &id);
private:
/**
diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
index 3f0319f9f..75d703b95 100644
--- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
+++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp
@@ -73,15 +73,16 @@ MountHelper::MountHelper() : TDEApplication()
KURL url(args->url(0));
const Medium medium = findMedium(url);
- if ( medium.id().isEmpty() )
+ if (medium.id().isEmpty())
{
- if (m_errorStr.isEmpty())
+ if (m_errorStr.isEmpty()) {
m_errorStr+= i18n("%1 cannot be found.").arg(url.prettyURL());
+ }
TQTimer::singleShot(0, this, TQT_SLOT(error()) );
return;
}
- if ( !medium.isMountable() && !args->isSet("e") && !args->isSet("s"))
+ if (!medium.isMountable() && !args->isSet("e") && !args->isSet("s"))
{
m_errorStr = i18n("%1 is not a mountable media.").arg(url.prettyURL());
TQTimer::singleShot(0, this, TQT_SLOT(error()) );
@@ -91,8 +92,7 @@ MountHelper::MountHelper() : TDEApplication()
TQString device = medium.deviceNode();
TQString mount_point = medium.mountPoint();
- m_isCdrom = medium.mimeType().find("dvd")!=-1
- || medium.mimeType().find("cd")!=-1;
+ m_isCdrom = medium.mimeType().find("dvd") != -1 || medium.mimeType().find("cd") != -1;
if (args->isSet("d"))
{
@@ -127,14 +127,19 @@ MountHelper::MountHelper() : TDEApplication()
else if (args->isSet("u"))
{
DCOPRef mediamanager("kded", "mediamanager");
- DCOPReply reply = mediamanager.call( "unmount", medium.id());
- if (reply.isValid())
- reply.get(m_errorStr);
- kdDebug() << "medium unmount " << m_errorStr << endl;
- if (m_errorStr.isNull())
+ DCOPReply reply = mediamanager.call("unmount", medium.id());
+ TQStringVariantMap unmountResult;
+ if (reply.isValid()) {
+ reply.get(unmountResult);
+ }
+ if (unmountResult.contains("result") && unmountResult["result"].toBool()) {
::exit(0);
- else
+ }
+ else {
+ m_errorStr = unmountResult.contains("errStr") ? unmountResult["errStr"].toString() : i18n("Unknown unmount error.");
+ kdDebug() << "medium unmount " << m_errorStr << endl;
error();
+ }
}
else if (args->isSet("s") || args->isSet("e"))
{
@@ -153,7 +158,11 @@ MountHelper::MountHelper() : TDEApplication()
{
DCOPReply reply = mediamanager.call( "unmount", medium.id());
if (reply.isValid()) {
- reply.get(m_errorStr);
+ TQStringVariantMap unmountResult;
+ reply.get(unmountResult);
+ if (unmountResult["result"].toBool()) {
+ reply.get(m_errorStr);
+ }
}
}
@@ -163,7 +172,11 @@ MountHelper::MountHelper() : TDEApplication()
{
DCOPReply reply = mediamanager.call( "undecrypt", medium.id());
if (reply.isValid()) {
- reply.get(m_errorStr);
+ TQStringVariantMap undecryptResult;
+ reply.get(undecryptResult);
+ if (undecryptResult["result"].toBool()) {
+ reply.get(m_errorStr);
+ }
}
}
@@ -177,13 +190,18 @@ MountHelper::MountHelper() : TDEApplication()
else
{
DCOPRef mediamanager("kded", "mediamanager");
- DCOPReply reply = mediamanager.call( "mount", medium.id());
- if (reply.isValid())
- reply.get(m_errorStr);
- if (m_errorStr.isNull())
+ DCOPReply reply = mediamanager.call("mount", medium.id());
+ TQStringVariantMap mountResult;
+ if (reply.isValid()) {
+ reply.get(mountResult);
+ }
+ if (mountResult.contains("result") && mountResult["result"].toBool()) {
::exit(0);
- else
+ }
+ else {
+ m_errorStr = mountResult.contains("errStr") ? mountResult["errStr"].toString() : i18n("Unknown mount error.");
error();
+ }
}
}
@@ -252,16 +270,18 @@ void MountHelper::slotSendPassword()
DCOPRef mediamanager("kded", "mediamanager");
DCOPReply reply = mediamanager.call( "decrypt", m_mediumId, dialog->getPassword() );
- if (!reply.isValid()) {
- m_errorStr = i18n("The TDE mediamanager is not running.");
+ TQStringVariantMap decryptResult;
+ if (reply.isValid()) {
+ reply.get(decryptResult);
+ }
+ if (decryptResult.contains("result") && decryptResult["result"].toBool()) {
+ ::exit(0);
+ }
+ else {
+ m_errorStr = decryptResult.contains("errStr") ? decryptResult["errStr"].toString() : i18n("Unknown decrypt error.");
+ kdDebug() << "medium decrypt " << m_errorStr << endl;
+ emit signalPasswordError(m_errorStr);
error();
- } else {
- TQString errorMsg = reply;
- if (errorMsg.isNull()) {
- exit(0);
- } else {
- emit signalPasswordError(errorMsg);
- }
}
}