Beispiel #1
0
StorageDevice::StorageDevice(const QString &udi, QObject *parent)
    : QObject(parent)
    , m_device(Solid::Device(udi))
    , m_ignored(false)
{
    qCDebug(DEVICE) << "Added storage device" << udi;

    Solid::StorageAccess *access = m_device.as<Solid::StorageAccess>();
    m_ignored = access->isIgnored();
    m_filePath = access->filePath();

    connect(access, &Solid::StorageAccess::setupDone,
            [this](Solid::ErrorType error, const QVariant &errorData, const QString &udi) {
        Q_UNUSED(error);
        Q_UNUSED(errorData);
        Q_UNUSED(udi);
        Q_EMIT mountedChanged();
    });
    connect(access, &Solid::StorageAccess::teardownDone,
            [this](Solid::ErrorType error, const QVariant &errorData, const QString &udi) {
        Q_UNUSED(error);
        Q_UNUSED(errorData);
        Q_UNUSED(udi);
        Q_EMIT mountedChanged();
    });
}
void
IpodCollectionFactory::createCollectionForSolidDevice( const QString &udi )
{
    DEBUG_BLOCK
    DeviceType type;
    QString mountPointOrUuid;
    Solid::Device device( udi );
    Solid::StorageAccess *ssa = device.as<Solid::StorageAccess>();
    if( ssa )
    {
        type = iPod;
        if( ssa->isIgnored() )
        {
            debug() << "device" << udi << "ignored, ignoring :-)";
            return;
        }

        // we are definitely interested in this device, listen for accessibility changes
        disconnect( ssa, SIGNAL(accessibilityChanged(bool,QString)), this, 0 );
        connect( ssa, SIGNAL(accessibilityChanged(bool,QString)),
                SLOT(slotAccessibilityChanged(bool,QString)) );

        if( !ssa->isAccessible() )
        {
            debug() << "device" << udi << "not accessible, ignoring for now";
            return;
        }
        mountPointOrUuid = ssa->filePath();
    }
    else // no ssa
    {
        do { // break inside this block means "continue with collection creation"