[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: [Patch] EjectPressed support for mediaIOSlave
From: "=?utf-8?q?S=2E=C3=87a=C4=9Flar?= Onur" <caglar () uludag ! org ! tr>
Date: 2006-02-28 21:12:36
Message-ID: 200602282312.42784.caglar () uludag ! org ! tr
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Salı 28 Şubat 2006 22:57 tarihinde, S.Çağlar Onur şunları yazmıştı:
> As you may already know hal started to support eject button pressed events
> for optical drives with version 0.5.5. If anyone interested, attached patch
> [against KDE-3.5.1] captures this events and unmounts & ejects mounted
> optical drive without breaking current API/ABI.
Correct patch attached [missing include added], sorry for multiple post.
Cheers
--
S.Çağlar Onur <caglar@uludag.org.tr>
http://cekirdek.uludag.org.tr/~caglar/
Linux is like living in a teepee. No Windows, no Gates and an Apache in house!
["kdebase-3.5.1-kioslave-ejectButton.patch" (text/x-diff)]
diff -ur kdebase-3.5.1.orig/kioslave/media/mediamanager/halbackend.cpp \
kdebase-3.5.1/kioslave/media/mediamanager/halbackend.cpp
--- kdebase-3.5.1.orig/kioslave/media/mediamanager/halbackend.cpp 2006-01-19 \
19:00:58.000000000 +0200
+++ kdebase-3.5.1/kioslave/media/mediamanager/halbackend.cpp 2006-02-28 \
23:06:02.000000000 +0200 @@ -22,6 +22,7 @@
#include <stdlib.h>
#include <klocale.h>
+#include <kprocess.h>
#include <kurl.h>
#include <kdebug.h>
@@ -278,6 +279,36 @@
ResetProperties(mediumUdi);
}
+void HALBackend::EjectDevice(const char* udi)
+{
+ kdDebug(1219) << "HALBackend::EjectDevice " << udi << endl;
+
+ /* Check if the device still exists */
+ if (!libhal_device_exists(m_halContext, udi, NULL))
+ return;
+
+ /* find drive from udi */
+ LibHalDrive* halDrive = libhal_drive_from_udi(m_halContext, udi);
+ if (!halDrive)
+ return;
+
+ /* get all volumes used by this drive */
+ int numVolumes;
+ char** volumes = libhal_drive_find_all_volumes(m_halContext, halDrive, \
&numVolumes); + if (numVolumes)
+ {
+ /* get block.device name from this volume properties */
+ QString device = hal_device_get_property_QString(m_halContext, volumes[0], \
"block.device"); +
+ /* unmount and eject device */
+ KProcess *proc = new KProcess(this);
+ *proc << "kio_media_mounthelper";
+ *proc << "-e";
+ *proc << device;
+ proc->start();
+ }
+}
+
void HALBackend::DeviceCondition(const char* udi, const char* condition)
{
const char* mediumUdi = findMediumUdiFromUdi(udi);
@@ -640,7 +671,12 @@
kdDebug(1219) << "HALBackend::hal_device_condition " << udi << " -- " << \
condition_name << endl; Q_UNUSED(ctx);
Q_UNUSED(message);
- s_HALBackend->DeviceCondition(udi, condition_name);
+
+ /* if EjectPressed signal emitted */
+ if(QString(condition_name) == "EjectPressed")
+ s_HALBackend->EjectDevice(udi);
+ else
+ s_HALBackend->DeviceCondition(udi, condition_name);
}
#include "halbackend.moc"
diff -ur kdebase-3.5.1.orig/kioslave/media/mediamanager/halbackend.h \
kdebase-3.5.1/kioslave/media/mediamanager/halbackend.h
--- kdebase-3.5.1.orig/kioslave/media/mediamanager/halbackend.h 2005-10-10 \
18:04:01.000000000 +0300
+++ kdebase-3.5.1/kioslave/media/mediamanager/halbackend.h 2006-02-28 \
23:05:44.000000000 +0200 @@ -176,6 +176,13 @@
*/
void DeviceCondition(const char *udi, const char *condition);
+ /**
+ * Eject button pressed, unmount and eject
+ *
+ * @param udi Universal Device Id
+ */
+ void EjectDevice(const char* udi);
+
/**
* Integrate the DBus connection within qt main loop
*/
[Attachment #8 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic