[Kde-hardware-devel] How to determine what drive an Optical Disc is in

Chris Gow sniffy at rogers.com
Thu Jan 31 14:25:39 CET 2008


On Thursday 31 January 2008 08:03:13 Kevin Ottens wrote:
> Le jeudi 31 janvier 2008, Chris Gow a écrit :
> > On Thursday 31 January 2008 03:22:05 Kevin Ottens wrote:
> > > Le mercredi 30 janvier 2008, Chris Gow a écrit :
> > > > If I have a Solid::OpticalDisc object, how do I find out what
> > > > device/drive it is mounted in?
> > > >
> > > > Solid::Device *d = new Solid::Device(someValidDeviceID);
> > > > Solid::OpticalDisc *opticalDisc = d->as<Solid::OpticalDisc>();
> > > >
> > > > QString mountedAt = /* eg. /dev/cdrom or some such */
> > >
> > > [I assume you meant "/media/cdrom", not "/dev/cdrom" which is not a
> > > mountpoint]
> >
> > Actually, I think either would do. But given my mistake, how can I
> > determine what device the CD is in?
>
> For the dev file:
> Solid::Block *block = d->as<Solid::Block>();
> QString deviceNode = block->device();
>
> Now I wonder what I should improve in the doc so that you could find this
> by yourself... Or you didn't dig in it, or I did something wrong (I guess
> it's the latter, there's room for improvement in the doc).
It could be both. I've been looking up info on techbase (the solid tutorials) 
and on api.kde.org. I know I'm having a hard time figuring out what a Device 
can be converted to. Especially when there isn't a direct inheritance 
hierarchy. In my case, I want to read info from various CDs, the closest 
solid class is OpticalDisc, so I read up on OpticalDisc, StorageVolume and 
the Drive classes. But I don't realize that I just have to 'cast' the device 
to some other class. 

Perhaps whats missing is a tutorial that demonstrates converting a device to 
multiple capabilities? And/Or providing an API that lists the Capabilities 
that a Device has?
>
> > > You have to use the StorageAccess interface on the same device object,
> > > which would give:
> > > Solid::StorageAccess *access = d->as<Solid::StorageAccess>();
> > > QString mountedAt = access->filePath();
> >
> > Ok, on my system (Kubuntu 7.10, KDE 4.0.0), I get the following:
> >
> > access->filePath() returns ""
> > access->isAccessable() returns false
> > access->setup() returns true
> > access->setupDone() contains errors:
> > Error Data  QVariant(QByteArray, "mount: block device /dev/scd0 is
> > write-protected, mounting read-only
> > mount: wrong fs type, bad option, bad superblock on /dev/scd0,
> >        missing codepage or helper program, or other error
> >        In some cases useful info is found in syslog - try
> >        dmesg | tail  or so
> >
> > I also get a number of empty return values when I deal with the
> > OpticalDisc object too. Not sure if it is a packaging problem, or because
> > the CD isn't mounted the methods don't return values.
>
> Because it's not mounted. Note that mounting makes sense only if it's a
> data cd. :-)
Makes sense.
>
> Regards.




More information about the Kde-hardware-devel mailing list