[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 0:31:35
Message-ID: 870c99310806101731n7e49cd5bj8b6097ad0520ce39 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

Thanks for the reply,
David


PS I am CCing the  hardware list by the way, but was unable to find the line
to subscribe to this group.



On Tue, Jun 10, 2008 at 3:16 PM, Christopher Blauvelt <cblauvelt@gmail.com>
wrote:

>
>
> On Tue, Jun 10, 2008 at 4:34 PM, David Boosalis <david.boosalis@gmail.com>
> wrote:
>
>> Hi All.
>>
>> My first time use of Solid as I want to capture in my application when a
>> USB Memory stick gets inserted into the computer.  I have no problem getting
>> the event, my question is how do I go from a Solid Class to a File Path, so
>> I can open up a file dialog on it.
>>
>> Here is my slot  thus far:
>>
>> void MyApp::slotSolidDeviceChanged(const QString &str)
>> {
>>   qDebug() << "Device changed " << str;
>>   QString filePath;
>>   Solid::Device device(str);
>>   Solid::DeviceInterface *deviceInterface;
>>   Solid::StorageAccess *accessStorage;
>>   Solid::StorageVolume *volumeStorage;
>>   if (device.isValid())
>>     {
>>       if (device.is<Solid::StorageAccess>()) {
>>     deviceInterface =
>> device.asDeviceInterface(Solid::DeviceInterface::StorageDrive);
>>
>>     usbStick = device.as<Solid::StorageDrive>();
>>
>>     volumeStorage = device.as<Solid::StorageVolume>();
>>     accessStorage = device.as<Solid::StorageAccess>();
>>     qDebug() << "file path  = " << accessStorage->filePath();   //
>> produces NULL code
>>     qDebug() << "uuid = " << volumeStorage->uuid();
>>     qDebug() << "Volumne Label = " << volumeStorage->label();
>>   }
>>
>>
> Dave,
> Are you sure the drive is mounted?  If not, then filePath() should return
> an empty string.  Make to use StorageAccess::setup.  This will mount the
> drive and, if successful, you should be able to get a file path.  Also, I've
> included kde-hardware-devel on this list.  Posting here will likely get you
> more attention from knowledgable people.
> Chris
>
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>
>

[Attachment #5 (text/html)]

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>Thanks for the reply,<br>David<br><br><br>PS I am \
CCing the&nbsp; hardware list by the way, but was unable to find the line to \
subscribe to this group.<br><br><br><br><div class="gmail_quote">On Tue, Jun 10, 2008 \
at 3:16 PM, Christopher Blauvelt &lt;<a \
href="mailto:cblauvelt@gmail.com">cblauvelt@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;"><div class="Ih2E3d"><br><br><div \
class="gmail_quote">On Tue, Jun 10, 2008 at 4:34 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 All.<br><br>My first time use of Solid as I want \
to capture in my application when a USB Memory stick gets inserted into the \
computer.&nbsp; I have no problem getting the event, my question is how do I go from \
a Solid Class to a File Path, so I can open up a file dialog on it.<br>


<br>Here is my slot&nbsp; thus far:<br><br>void MyApp::slotSolidDeviceChanged(const \
QString &amp;str)<br>{<br>&nbsp; qDebug() &lt;&lt; &quot;Device changed &quot; \
&lt;&lt; str;<br>&nbsp; QString filePath;<br>&nbsp; Solid::Device device(str);<br>


&nbsp; Solid::DeviceInterface *deviceInterface;<br>&nbsp; Solid::StorageAccess \
*accessStorage;<br>&nbsp; Solid::StorageVolume *volumeStorage;<br>&nbsp; if \
(device.isValid())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (<a \
href="http://device.is" target="_blank">device.is</a>&lt;Solid::StorageAccess&gt;()) \
{<br>


&nbsp;&nbsp;&nbsp; deviceInterface = \
device.asDeviceInterface(Solid::DeviceInterface::StorageDrive);<br><br>&nbsp;&nbsp;&nbsp; \
usbStick = <a href="http://device.as" \
target="_blank">device.as</a>&lt;Solid::StorageDrive&gt;();<br><br>&nbsp;&nbsp;&nbsp; \
volumeStorage = <a href="http://device.as" \
target="_blank">device.as</a>&lt;Solid::StorageVolume&gt;();<br>


&nbsp;&nbsp;&nbsp; accessStorage = <a href="http://device.as" \
target="_blank">device.as</a>&lt;Solid::StorageAccess&gt;();<br>&nbsp;&nbsp;&nbsp; \
qDebug() &lt;&lt; &quot;file path&nbsp; = &quot; &lt;&lt; \
accessStorage-&gt;filePath();&nbsp;&nbsp; // produces NULL code<br>

&nbsp;&nbsp;&nbsp; qDebug() &lt;&lt; &quot;uuid = &quot; &lt;&lt; \
volumeStorage-&gt;uuid();<br> &nbsp;&nbsp;&nbsp; qDebug() &lt;&lt; &quot;Volumne \
Label = &quot; &lt;&lt; volumeStorage-&gt;label(); <br>&nbsp; \
}<br><br></blockquote></div><br></div>Dave,<br>Are you sure the drive is \
mounted?&nbsp; If not, then filePath() should return an empty string.&nbsp; Make to \
use StorageAccess::setup.&nbsp; This will mount the drive and, if successful, you \
should be able to get a file path.&nbsp; Also, I&#39;ve included kde-hardware-devel \
on this list.&nbsp; Posting here will likely get you more attention from knowledgable \
people.<br>

Chris<br>
<br><br>
&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></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