[Kde-hardware-devel] Solid - how to get path of storage device
David Boosalis
david.boosalis at gmail.com
Wed Jun 11 09:34:50 CEST 2008
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 at gmail.com>
wrote:
>
>
> On Tue, Jun 10, 2008 at 7:31 PM, David Boosalis <david.boosalis at 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 <<
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20080611/fc6341d8/attachment.html
More information about the Kde-hardware-devel
mailing list