[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Solid - how to get path of storage device
From: "David Boosalis" <david.boosalis () gmail ! com>
Date: 2008-06-11 7:41:52
Message-ID: 870c99310806110041p2358c607h64e87f22e6f48b76 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I think I found the issue.
I need to listen for this signal:
void Solid::StorageAccessible::setupDone<http://api.kde.org/4.x-api/kdelibs-apidocs/solid/html/classSolid_1_1StorageAccess.html#e58d855de4fe07aaf4639ebdc2c95989>(
Solid::ErrorType<http://api.kde.org/4.x-api/kdelibs-apidocs/solid/html/namespaceSolid.html#30fa3c763cbafcd3f5b8ce3af063369b>error,
QVariant <http://doc.trolltech.com/4.3/qvariant.html> errorData, const
QString <http://doc.trolltech.com/4.3/qstring.html> &udi)
On Wed, Jun 11, 2008 at 12:34 AM, David Boosalis <david.boosalis@gmail.com>
wrote:
> Chis your answers are clear as day, but I still can't get the filePath.to
> print out.
>
> So this is what I have, pretty much verbatim of what you have:
> MySlot(QString str)
> {
> QString filePath;
> Solid::Device device(str);
> Solid::StorageAccess *storageAccess = device.as<Solid::StorageAccess>();
> if(storageAccess) {
> if(!storageAccess->isAccessible()) { //device is plugged in but not
> mounted
> qDebug() << "Make accesible...";
> storageAccess->setup();
> }
> qDebug() << "File path is: " << storageAccess->filePath();
> setupSelectedSlot(SetupDashBoardView::FileSettings);
> }
>
> Here is the output form the command line when a usb is device is loaded
> (the results are the same on two computers)
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic"
> Device changed
> "/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0"
> Device changed "/org/freedesktop/Hal/devices/volume_uuid_7062_BD74"
> Make accesible...
> File path is: ""
>
> As you can see setup() is called.
>
>
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0"
> Device changed
> "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic"
> Device changed
> "/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0"
> Device changed "/org/freedesktop/Hal/devices/volume_uuid_7062_BD74"
> Make accesible...
> File path is: ""
>
> Could it be a timing issue. Or do you have any ideas
>
> Regards
> David
>
>
>
> On Tue, Jun 10, 2008 at 7:10 PM, Christopher Blauvelt <cblauvelt@gmail.com>
> wrote:
>
> >
> >
> > On Tue, Jun 10, 2008 at 7:31 PM, David Boosalis <david.boosalis@gmail.com>
> > wrote:
> >
> > > Hi Chris.
> > >
> > > The signal gets generated from a USB being plugged in. I use the
> > > following to connect the signal to the slog given:
> > >
> > > connect(DeviceNotifier::instance(),
> > > SIGNAL(deviceAdded(const QString &)),
> > > this,
> > > SLOT(slotSolidDeviceChanged(const QString &)));
> > >
> > > connect(Solid::DeviceNotifier::instance(),
> > > SIGNAL(deviceRemoved(const QString &)),
> > > this,
> > > SLOT(slotSolidDeviceChanged(const QString &)));
> > >
> > > This was taken from the solid tutorial. Maybe I am getting an extraneous
> > > signal when I plug in the usb stick because the qDebug statement for
> > > filePath below prints nothing for hte filePath argument. I am using hte
> > > latest build of the depot for all my coding work. You mentioned something
> > > about StorgeAccess::setup(), I'll research this call, as I am not sure where
> > > to put it.
> > >
> > > filePath() gives you the path to where the device is *mounted*. The
> > signal you're receiving is sent when the device is plugged in, regardless of
> > whether it's mounted or not. If you plug in your USB device, and it's not
> > mounted you catch the signal that a device was added but since it's not
> > mounted filePath() will return QString().
> >
> > Try this in your slot:
> > qDebug() << "Device changed " << str;
> > QString filePath;
> > Solid::Device device(str);
> > Solid::StorageAccess *accessStorage = device.as
> > <Solid::StorageAccess>();
> > if(storageAccess) {
> > if(!storageAccess->isAccessible()) { //device is plugged in but not
> > mounted
> > storageAccess->setup();
> > }
> > qDebug() << "File path is: " << storageAccess->filePath();
> > }
> >
> >
> > > > Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> > unsubscribe <<
> >
> >
>
[Attachment #5 (text/html)]
I think I found the issue.<br><br>I need to listen for this signal:<br><br> void \
Solid::StorageAccessible::<a class="el" \
href="http://api.kde.org/4.x-api/kdelibs-apidocs/solid/html/classSolid_1_1StorageAccess.html#e58d855de4fe07aaf4639ebdc2c95989">setupDone</a> \
(<a class="el" href="http://api.kde.org/4.x-api/kdelibs-apidocs/solid/html/namespaceSolid.html#30fa3c763cbafcd3f5b8ce3af063369b">Solid::ErrorType</a> \
error, <a class="elRef" \
href="http://doc.trolltech.com/4.3/qvariant.html">QVariant</a> errorData, const <a \
class="elRef" href="http://doc.trolltech.com/4.3/qstring.html">QString</a> \
&udi)<br> <br><div class="gmail_quote">On Wed, Jun 11, 2008 at 12:34 AM, David \
Boosalis <<a href="mailto:david.boosalis@gmail.com">david.boosalis@gmail.com</a>> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Chis your answers are clear as \
day, but I still can't get the filePath.to print out.<br><br>So this is what I \
have, pretty much verbatim of what you have:<br>MySlot(QString str)<div \
class="Ih2E3d"><br>{<br> QString filePath;<br> Solid::Device \
device(str);<br></div> Solid::StorageAccess *storageAccess = <a \
href="http://device.as" \
target="_blank">device.as</a><Solid::StorageAccess>();<div \
class="Ih2E3d"><br> if(storageAccess) {<br> \
if(!storageAccess->isAccessible()) { //device is plugged in but not mounted<br> \
</div> qDebug() << "Make \
accesible...";<div class="Ih2E3d"><br> \
storageAccess->setup();<br> }<br> \
qDebug() << "File path is: " << \
storageAccess->filePath();<br></div> \
setupSelectedSlot(SetupDashBoardView::FileSettings);<br> }<br><br>Here is the \
output form the command line when a usb is device is loaded (the results are the same \
on two computers)<br>Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774"<br>
Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0"<br>Device \
changed "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host"<br>Device \
changed "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0"<br>
Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic"<br>Device \
changed "/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0"<br>
Device changed \
"/org/freedesktop/Hal/devices/volume_uuid_7062_BD74"<br>Make \
accesible...<br>File path is: ""<br><br>As you can see setup() is \
called. <br><br><br>Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774"<br>
Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0"<br>Device \
changed "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host"<br>Device \
changed "/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0"<br>
Device changed \
"/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic"<br>Device \
changed "/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0"<br>
Device changed \
"/org/freedesktop/Hal/devices/volume_uuid_7062_BD74"<br>Make \
accesible...<br>File path is: ""<br><br>Could it be a timing issue. \
Or do you have any ideas<br><br>Regards<br><font color="#888888">David<br> <br>
<br><br></font><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Tue, \
Jun 10, 2008 at 7:10 PM, Christopher Blauvelt <<a \
href="mailto:cblauvelt@gmail.com" target="_blank">cblauvelt@gmail.com</a>> \
wrote:<br> </div></div><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: \
1ex;"><div><div></div><div class="Wj3C7c"> <div><br><br><div class="gmail_quote">On \
Tue, Jun 10, 2008 at 7:31 PM, David Boosalis <<a \
href="mailto:david.boosalis@gmail.com" \
target="_blank">david.boosalis@gmail.com</a>> wrote:<br><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;">
Hi Chris.<br><br>The signal gets generated from a USB being plugged in. I use \
the following to connect the signal to the slog given:<br><br> \
connect(DeviceNotifier::instance(), <br> \
SIGNAL(deviceAdded(const QString &)),<br>
this, <br> \
SLOT(slotSolidDeviceChanged(const QString &)));<br> <br> \
connect(Solid::DeviceNotifier::instance(), <br> \
SIGNAL(deviceRemoved(const QString &)),<br> this, \
<br> SLOT(slotSolidDeviceChanged(const QString &)));<br>
<br>This was taken from the solid tutorial. Maybe I am getting an extraneous signal \
when I plug in the usb stick because the qDebug statement for filePath below prints \
nothing for hte filePath argument. I am using hte latest build of the depot for all \
my coding work. You mentioned something about StorgeAccess::setup(), I'll \
research this call, as I am not sure where to put it.<br>
<br></blockquote></div></div>filePath() gives you the path to where the device is \
*mounted*. The signal you're receiving is sent when the device is plugged \
in, regardless of whether it's mounted or not. If you plug in your USB \
device, and it's not mounted you catch the signal that a device was added but \
since it's not mounted filePath() will return QString().<br>
<br>Try this in your slot:<div><br>qDebug() << "Device changed " \
<< str;<br> QString filePath;<br> Solid::Device \
device(str);<br></div> Solid::StorageAccess *accessStorage = <a \
href="http://device.as" \
target="_blank">device.as</a><Solid::StorageAccess>();<br>
if(storageAccess) {<br> \
if(!storageAccess->isAccessible()) { //device is plugged in but not \
mounted<br> \
storageAccess->setup();<br> }<br> \
qDebug() << "File path is: " << \
storageAccess->filePath();<br>
}<br>
<br><br></div></div><div class="Ih2E3d">
>> Visit <a href="http://mail.kde.org/mailman/listinfo/kde-devel#unsub" \
target="_blank">http://mail.kde.org/mailman/listinfo/kde-devel#unsub</a> to \
unsubscribe <<<br> <br></div></blockquote></div><br>
</blockquote></div><br>
>> 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