This instance will be upgraded to Heptapod 0.20.1 on 2020-03-08 at 14:00 UTC+1 (10 minutes of downtime)

Commit 54937ed1 authored by Gleb Popov's avatar Gleb Popov

Implement Drive::Eject method.

parent 9f20a9d906ec
......@@ -24,8 +24,39 @@
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QProcess>
#include "drive.h"
void Drive::Eject(const QVariantMap &options)
{
if(!optical())
return;
int fd = open("/dev/cd0", O_RDONLY);
if (fd < 0 && errno != ENXIO) {
QString errorMessage = ::strerror(errno);
connection().send(message().createErrorReply("org.freedesktop.UDisks2.Error.Failed", errorMessage));
qDebug() << "Eject failed: " << errorMessage;
return;
}
::ioctl(fd, CDIOCALLOW);
int rc = ::ioctl(fd, CDIOCEJECT);
if (rc < 0) {
QString errorMessage = ::strerror(errno);
connection().send(message().createErrorReply("org.freedesktop.UDisks2.Error.Failed", errorMessage));
qDebug() << "Eject failed: " << errorMessage;
return;
}
}
Configuration Drive::configuration() const
{
Configuration c;
......
......@@ -32,7 +32,8 @@
#include "adaptors.h"
#include "camcontrolprober.h"
class Drive : public QObject
class Drive : public QObject,
public QDBusContext
{
Q_OBJECT
public:
......@@ -86,4 +87,7 @@ public:
Q_PROPERTY(QString bsdisks_AtaSata READ bsdisks_AtaSataR)
QString bsdisks_AtaSataR() const;
public slots:
void Eject(const QVariantMap &options);
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment