|
|
@ -64,8 +64,41 @@ TQStringVariantMap udisksEjectDrive(TDEStorageDevice *sdevice) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
result["result"] = true;
|
|
|
|
// Eject was successful. Check if the media can be powered off and do so in case
|
|
|
|
return result;
|
|
|
|
TQT_DBusProxy driveInformation("org.freedesktop.UDisks", blockDeviceString,
|
|
|
|
|
|
|
|
"org.freedesktop.DBus.Properties", dbusConn);
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromString("org.freedesktop.UDisks.Drive") << TQT_DBusData::fromString("DriveCanDetach");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error);
|
|
|
|
|
|
|
|
if (error.isValid()) {
|
|
|
|
|
|
|
|
// Error!
|
|
|
|
|
|
|
|
result["errStr"] = error.name() + ": " + error.message();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
|
|
|
|
bool canPowerOff = reply[0].toVariant().value.toBool();
|
|
|
|
|
|
|
|
if (!canPowerOff) {
|
|
|
|
|
|
|
|
// This drive does not support power off. Just return since the eject operation has finished.
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Power off the drive!
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
|
|
|
|
TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant);
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromStringKeyMap(options);
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = driveControl.sendWithReply("DriveDetach", params, &error);
|
|
|
|
|
|
|
|
if (error.isValid()) {
|
|
|
|
|
|
|
|
// Error!
|
|
|
|
|
|
|
|
result["errStr"] = error.name() + ": " + error.message();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -193,7 +226,7 @@ TQStringVariantMap udisks2EjectDrive(TDEStorageDevice *sdevice) {
|
|
|
|
TQT_DBusProxy driveInformation("org.freedesktop.UDisks2", driveObjectPath,
|
|
|
|
TQT_DBusProxy driveInformation("org.freedesktop.UDisks2", driveObjectPath,
|
|
|
|
"org.freedesktop.DBus.Properties", dbusConn);
|
|
|
|
"org.freedesktop.DBus.Properties", dbusConn);
|
|
|
|
// can eject?
|
|
|
|
// can eject?
|
|
|
|
TQValueList<TQT_DBusData> params;
|
|
|
|
params.clear();
|
|
|
|
params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("Ejectable");
|
|
|
|
params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("Ejectable");
|
|
|
|
TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error);
|
|
|
|
TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error);
|
|
|
|
if (error.isValid()) {
|
|
|
|
if (error.isValid()) {
|
|
|
@ -211,7 +244,7 @@ TQStringVariantMap udisks2EjectDrive(TDEStorageDevice *sdevice) {
|
|
|
|
|
|
|
|
|
|
|
|
// Eject the drive!
|
|
|
|
// Eject the drive!
|
|
|
|
TQT_DBusProxy driveControl("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.UDisks2.Drive", dbusConn);
|
|
|
|
TQT_DBusProxy driveControl("org.freedesktop.UDisks2", driveObjectPath, "org.freedesktop.UDisks2.Drive", dbusConn);
|
|
|
|
TQValueList<TQT_DBusData> params;
|
|
|
|
params.clear();
|
|
|
|
TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant);
|
|
|
|
TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant);
|
|
|
|
params << TQT_DBusData::fromStringKeyMap(options);
|
|
|
|
params << TQT_DBusData::fromStringKeyMap(options);
|
|
|
|
TQT_DBusMessage reply = driveControl.sendWithReply("Eject", params, &error);
|
|
|
|
TQT_DBusMessage reply = driveControl.sendWithReply("Eject", params, &error);
|
|
|
@ -221,8 +254,39 @@ TQStringVariantMap udisks2EjectDrive(TDEStorageDevice *sdevice) {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
result["result"] = true;
|
|
|
|
// Eject was successful. Check if the media can be powered off and do so in case
|
|
|
|
return result;
|
|
|
|
params.clear();
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromString("org.freedesktop.UDisks2.Drive") << TQT_DBusData::fromString("CanPowerOff");
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = driveInformation.sendWithReply("Get", params, &error);
|
|
|
|
|
|
|
|
if (error.isValid()) {
|
|
|
|
|
|
|
|
// Error!
|
|
|
|
|
|
|
|
result["errStr"] = error.name() + ": " + error.message();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
|
|
|
|
|
|
|
|
bool canPowerOff = reply[0].toVariant().value.toBool();
|
|
|
|
|
|
|
|
if (!canPowerOff) {
|
|
|
|
|
|
|
|
// This drive does not support power off. Just return since the eject operation has finished.
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Power off the drive!
|
|
|
|
|
|
|
|
params.clear();
|
|
|
|
|
|
|
|
TQT_DBusDataMap<TQString> options(TQT_DBusData::Variant);
|
|
|
|
|
|
|
|
params << TQT_DBusData::fromStringKeyMap(options);
|
|
|
|
|
|
|
|
TQT_DBusMessage reply = driveControl.sendWithReply("PowerOff", params, &error);
|
|
|
|
|
|
|
|
if (error.isValid()) {
|
|
|
|
|
|
|
|
// Error!
|
|
|
|
|
|
|
|
result["errStr"] = error.name() + ": " + error.message();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
result["result"] = true;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|