Am 23.12.2012 23:40, schrieb John Paul Adrian Glaubitz:
O.K., i know you want to discuss autodetection function first but i'm just playing arround a bit ;)On Sun, Dec 23, 2012 at 09:20:44PM +0100, Thomas Arp wrote:I took a look at udev-discoverer gui application to see which information we can get from udev. Is there any way to get the mountpoint? I cannot find anything about that.I don't think you can. The basic idea of udev is to trigger on hardware events and changes and then set up devices files or call external programs according to the rules files.
That's what i changed yet:- created a dbus connection and service with methods "AddMDDevice" and "RemoveMDDevice" listening to the session bus - getting mountpoint via system bus, also add function to mount the device via system bus if it is not mounted
As qdbus is a part of Qt and qhimdtransfer depends on Qt, qdbus should be present on all machines where qhimdtransfer is installed.
So we can use it to send messages to the session bus. TODO: create udev rule to use qdbus to send a message with following syntax:RUN+="qdbus com.trolltech.Qt /QHiMDUnixDetection AddMDDevice <device file> <vid> <pid>"
(and RemoveMDDevice for ACTION=="remove")where <device file> is the corresponding kernel driver sdX (without path, just driver name!!)
<vid> and <pid> are vendor/product id as integers,i think they have to be converted to decimal instead of hexadecimal, sending a message with 0x054c as vid doesn't work.
I tested this by sending these messages with qdbus manually in a terminal and it works fine this way. I have to read a bit more about creating udev rules. I didn't create a working rule yet, i don't know how to set the arguments to the dbus command line correctly. But maybe it is better to use an extra script instead of sending the message in the rule itself.
You can find it in netmd_integration2 branch at my github accout .If this doesn't compile because of linker errors please recreate moc_qhimdunixdetection.cpp manually (type "moc qhimdunixdetection.cpp > moc_qhimdunixdetection.cpp" in qhimdtransfer directory).
Thomas  http://github.com/tharp/linux-minidisc