[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Bug in getting device interfaces with Solid ?
From:       "Christopher Blauvelt" <cblauvelt () gmail ! com>
Date:       2008-07-09 18:58:16
Message-ID: ffa898c90807091158g2e5aa88aif006a7d6649109fb () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Wed, Jul 9, 2008 at 1:27 PM, David Boosalis <david.boosalis@gmail.com>
wrote:

> When I start my KDE application, I would like to know if a USB stick is
> already mounted.  I have implemented the following code as an example:
>
>  Solid::Device device;
>   KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
>   QList< Solid::Device > storageDevices =
>     Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive);
>
>   kDebug() << "Storeage List Count = " << storageDevices.count();
>   QListIterator <Solid::Device > iter(storageDevices);
>   Solid::DeviceInterface *di;
>   Solid::StorageDrive *storageDrive;
>   while(iter.hasNext()) {
>     device = iter.next();
>     di = device.asDeviceInterface(Solid::DeviceInterface::StorageDrive);
>     storageDrive = (Solid::StorageDrive *) di;
>     if (storageDrive) {
>       kDebug() << "is storage drive, type = " << storageDrive->driveType();
>       kDebug() << "bus type = " << storageDrive->bus();
>       if (storageDrive->driveType() == Solid::StorageDrive::MemoryStick) {
>     kDebug() << "Hey we have a memory stick....";
>     break;
>       }
>     }
>   }
>
>
> On my laptop without a memory stick plugged in I get the following:
>
> .Storeage List Count =  2
> .is storage drive, type =  1
> bus type =  3
> is storage drive, type =  0
>  bus type =  3
>
>
> I think these refer to the Linux partion of my hard drive as well as the
> ntfs windows partion.
>
> Now when I plug in a usb card and then run. It show three drives as shown
> in the following output:
>
> Storeage List Count =  3
> s storage drive, type =  0
> bus type =  1
> is storage drive, type =  1
> bus type =  3
> is storage drive, type =  0
> bus type =  3
>
> Why doesn't the usb stick have a type of Solid::StorageDrive::MemoryStick
> and why is not the bustype  reported as a USB bus.  Is my thinking wrong
> here, if so what do you recommen in order to determine if a usb memory stick
> is already inserted when my application starts up.
>
> By the way I am running Kubuntu with KDE Trunk (last updated July 8)
>
> Thank yo uin advance for any help
>
>
>
>
>
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>
>
The first thing to do would be to plug-in the device and query it using
SolidShell.  If that's not giving you the data that you expect then it's
likely an issue with Hal.  Use hal-info to query the device, if it's not
what you expect then you'll need to file a bug with Hal.  If hal is
reporting the right information but no Solid, just let us know.
Chris

[Attachment #5 (text/html)]

<br><br>
<div class="gmail_quote">On Wed, Jul 9, 2008 at 1:27 PM, David Boosalis &lt;<a \
href="mailto:david.boosalis@gmail.com">david.boosalis@gmail.com</a>&gt; wrote:<br> \
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; \
BORDER-LEFT: #ccc 1px solid">When I start my KDE application, I would like to know if \
a USB stick is already mounted.&nbsp; I have implemented the following code as an \
example:<br> <br>&nbsp;Solid::Device device;<br>&nbsp; KCmdLineArgs* args = \
KCmdLineArgs::parsedArgs();<br>&nbsp; QList&lt; Solid::Device &gt; storageDevices \
=<br>&nbsp;&nbsp;&nbsp; \
Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive);<br><br>&nbsp; \
kDebug() &lt;&lt; &quot;Storeage List Count = &quot; &lt;&lt; \
storageDevices.count();<br> &nbsp; QListIterator &lt;Solid::Device &gt; \
iter(storageDevices);<br>&nbsp; Solid::DeviceInterface *di;<br>&nbsp; \
Solid::StorageDrive *storageDrive;<br>&nbsp; while(iter.hasNext()) \
{<br>&nbsp;&nbsp;&nbsp; device = iter.next();<br>&nbsp;&nbsp;&nbsp; di = \
device.asDeviceInterface(Solid::DeviceInterface::StorageDrive);<br> \
&nbsp;&nbsp;&nbsp; storageDrive = (Solid::StorageDrive *) di;<br>&nbsp;&nbsp;&nbsp; \
if (storageDrive) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kDebug() &lt;&lt; &quot;is \
storage drive, type = &quot; &lt;&lt; \
storageDrive-&gt;driveType();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kDebug() &lt;&lt; \
&quot;bus type = &quot; &lt;&lt; storageDrive-&gt;bus();<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (storageDrive-&gt;driveType() == \
Solid::StorageDrive::MemoryStick) {<br>&nbsp;&nbsp;&nbsp; kDebug() &lt;&lt; &quot;Hey \
we have a memory stick....&quot;;<br>&nbsp;&nbsp;&nbsp; \
break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; \
}<br><br><br>On my laptop without a memory stick plugged in I get the following:<br> \
<br>.Storeage List Count =&nbsp; 2<br>.is storage drive, type =&nbsp; 1<br>bus type \
=&nbsp; 3<br>is storage drive, type =&nbsp; 0<br>&nbsp;bus type =&nbsp; \
3<br><br><br>I think these refer to the Linux partion of my hard drive as well as the \
ntfs windows partion.<br> <br>Now when I plug in a usb card and then run. It show \
three drives as shown in the following output:<br><br>Storeage List Count =&nbsp; \
3<br>s storage drive, type =&nbsp; 0<br>bus type =&nbsp; 1<br>is storage drive, type \
=&nbsp; 1<br>bus type =&nbsp; 3<br> is storage drive, type =&nbsp; 0<br>bus type \
=&nbsp; 3<br><br>Why doesn&#39;t the usb stick have a type of \
Solid::StorageDrive::MemoryStick and why is not the bustype&nbsp; reported as a USB \
bus.&nbsp; Is my thinking wrong here, if so what do you recommen in order to \
determine if a usb memory stick is already inserted when my application starts \
up.<br> <br>By the way I am running Kubuntu with KDE Trunk (last updated July \
8)<br><br>Thank yo uin advance for any help<br><br><br><br><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>
<div>&nbsp;</div>
<div>The first thing to do would be to plug-in the device and query it using \
SolidShell.&nbsp; If that&#39;s not giving you the data that you expect then it&#39;s \
likely an issue with Hal.&nbsp; Use hal-info to query the device, if it&#39;s not \
what you expect then you&#39;ll need to file a bug with Hal.&nbsp; If hal is \
reporting the right information but no Solid, just let us know.</div>

<div>Chris<br></div>



>> 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