[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Problems with Solid in kio-slave (Slots not called, properties not updated)
From: Philipp Schmidt <philschmidt () gmx ! net>
Date: 2013-02-11 15:54:30
Message-ID: 3487024.3lIyFvrMsx () sam
[Download RAW message or body]
Hi,
I would like my kio_mtp slave to be notified by Solid::DeviceNotifier events.
However I can't get the Solid::Devicenotifier to work within my helper thread,
as slots apparently can't be called from slave itself. A QTimer::singleShot()
works fine. The exact same code, put into a simple QCoreApplication works like
a charm.
The implementation in the slave constructor is like this:
>>>>>
ExampleClass *ex = new ExampleClass();
helperThread = new QThread( this );
ex->moveToThread(helperThread);
helperThread->start();
<<<<<
In the ExampleClass:
>>>>>
ExampleClass::ExampleClass ( QObject* parent )
{
QTimer::singleShot(0, this, SLOT(test()));
Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance();
connect( notifier, SIGNAL( deviceAdded(QString) ), this, SLOT(test()) );
connect( notifier, SIGNAL( deviceRemoved(QString) ), this, SLOT(test()) );
}
void ExampleClass::test()
{
kDebug( 7000 ) << "TestTestTest";
}
<<<<<
The sample project with the code from the top is located at
http://dl.dropbox.com/u/14496907/testslave.tar.gz
Right now I am retrieving the devices using a foreach loop.
>>>>>
foreach ( Solid::Device solidDevice, Solid::Device::listFromType(
Solid::DeviceInterface::PortableMediaPlayer, QString() ) )
{
Solid::GenericInterface *iface =
solidDevice.as<Solid::GenericInterface>();
QMap<QString, QVariant> properties = iface->allProperties();
int solidBusNum =
properties.value ( QLatin1String ( "BUSNUM" ) ).toInt();
int solidDevNum =
properties.value ( QLatin1String ( "DEVNUM" ) ).toInt();
//...
}
<<<<<
However, there the properties are not updated if the device is unplugged und
plugged in again (The udi doesn't change, only USB busnum/devnum that LIBMTP
uses for identification.
So, why is it that Solid won't work in KIO-Slaves like its supposed to?
Cheers,
Philipp
>> 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