[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>&nbsp;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> \
&amp;udi)<br> <br><div class="gmail_quote">On Wed, Jun 11, 2008 at 12:34 AM, David \
Boosalis &lt;<a href="mailto:david.boosalis@gmail.com">david.boosalis@gmail.com</a>&gt; \
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&#39;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>&nbsp; QString filePath;<br> &nbsp; Solid::Device \
device(str);<br></div> &nbsp; Solid::StorageAccess *storageAccess = <a \
href="http://device.as" \
target="_blank">device.as</a>&lt;Solid::StorageAccess&gt;();<div \
class="Ih2E3d"><br>&nbsp; if(storageAccess) {<br>&nbsp;&nbsp;&nbsp;&nbsp; \
if(!storageAccess-&gt;isAccessible()) { //device is plugged in but not mounted<br> \
</div> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qDebug() &lt;&lt; &quot;Make \
accesible...&quot;;<div class="Ih2E3d"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
storageAccess-&gt;setup();<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; \
qDebug() &lt;&lt; &quot;File path is: &quot; &lt;&lt; \
storageAccess-&gt;filePath();<br></div> &nbsp;&nbsp;&nbsp;&nbsp; \
setupSelectedSlot(SetupDashBoardView::FileSettings);<br> &nbsp; }<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&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774&quot;<br>

Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0&quot;<br>


Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0&quot;<br>


Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/volume_uuid_7062_BD74&quot;<br>Make \
accesible...<br>File path is:&nbsp; &quot;&quot;<br><br>As you can see setup() is \
called.&nbsp; <br><br><br>Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774&quot;<br>

Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0&quot;<br>


Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/usb_device_951_1603_0000024774_if0_scsi_host_scsi_device_lun0_scsi_generic&quot;<br>Device \
changed&nbsp; &quot;/org/freedesktop/Hal/devices/storage_serial_Kingston_DataTraveler_2_0_0000024774_0_0&quot;<br>


Device changed&nbsp; \
&quot;/org/freedesktop/Hal/devices/volume_uuid_7062_BD74&quot;<br>Make \
accesible...<br>File path is:&nbsp; &quot;&quot;<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 &lt;<a \
href="mailto:cblauvelt@gmail.com" target="_blank">cblauvelt@gmail.com</a>&gt; \
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 &lt;<a \
href="mailto:david.boosalis@gmail.com" \
target="_blank">david.boosalis@gmail.com</a>&gt; 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.&nbsp; I use \
the following to connect the signal to the slog given:<br><br>&nbsp; \
connect(DeviceNotifier::instance(), <br>&nbsp;&nbsp;&nbsp; &nbsp; \
SIGNAL(deviceAdded(const QString &amp;)),<br>



&nbsp;&nbsp;&nbsp; &nbsp; this, <br>&nbsp;&nbsp;&nbsp; &nbsp; \
SLOT(slotSolidDeviceChanged(const QString &amp;)));<br>&nbsp; <br>&nbsp; \
connect(Solid::DeviceNotifier::instance(), <br>&nbsp;&nbsp;&nbsp; &nbsp; \
SIGNAL(deviceRemoved(const QString &amp;)),<br>&nbsp;&nbsp;&nbsp; &nbsp; this, \
<br>&nbsp;&nbsp;&nbsp; &nbsp; SLOT(slotSolidDeviceChanged(const QString &amp;)));<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.&nbsp; You mentioned something about StorgeAccess::setup(), I&#39;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*.&nbsp; The signal you&#39;re receiving is sent when the device is plugged \
in, regardless of whether it&#39;s mounted or not.&nbsp; If you plug in your USB \
device, and it&#39;s not mounted you catch the signal that a device was added but \
since it&#39;s not mounted filePath() will return QString().<br>


<br>Try this in your slot:<div><br>qDebug() &lt;&lt; &quot;Device changed &quot; \
&lt;&lt; str;<br>&nbsp; QString filePath;<br>&nbsp; Solid::Device \
device(str);<br></div>&nbsp; Solid::StorageAccess *accessStorage = <a \
href="http://device.as" \
target="_blank">device.as</a>&lt;Solid::StorageAccess&gt;();<br>


&nbsp; if(storageAccess) {<br>&nbsp;&nbsp;&nbsp;&nbsp; \
if(!storageAccess-&gt;isAccessible()) { //device is plugged in but not \
mounted<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
storageAccess-&gt;setup();<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; \
qDebug() &lt;&lt; &quot;File path is: &quot; &lt;&lt; \
storageAccess-&gt;filePath();<br>


&nbsp; }<br>
<br><br></div></div><div class="Ih2E3d">
&gt;&gt; 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 &lt;&lt;<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