void SolidDeviceJob::start() { Solid::Device device (m_dest); QString operation = operationName(); if (operation == QLatin1String("mount")) { if (device.is<Solid::StorageAccess>()) { Solid::StorageAccess *access = device.as<Solid::StorageAccess>(); if (access && !access->isAccessible()) { access->setup(); } } } else if (operation == QLatin1String("unmount")) { if (device.is<Solid::OpticalDisc>()) { Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>(); if (!drive) { drive = device.parent().as<Solid::OpticalDrive>(); } if (drive) { drive->eject(); } } else if (device.is<Solid::StorageAccess>()) { Solid::StorageAccess *access = device.as<Solid::StorageAccess>(); if (access && access->isAccessible()) { access->teardown(); } } } emitResult(); }
void MenuDiskItem::diskButtonClicked() { mDiskButtonClicked = true; Solid::StorageAccess* di = mDevice.as<Solid::StorageAccess>(); if (!di->isAccessible()) di->setup(); else onMounted(Solid::NoError, QString(), mDevice.udi()); mPopup->hide(); }
void MenuDiskItem::diskButtonClicked() { mDiskButtonClicked = true; Solid::StorageAccess* di = mDevice.as<Solid::StorageAccess>(); if (!di->isAccessible()) di->setup(); else mounted(Solid::NoError, QString(), mDevice.udi()); qobject_cast<QWidget*>(parent())->hide(); }
void PlacesItemModel::requestStorageSetup(int index) { const PlacesItem* item = placesItem(index); if (!item) { return; } Solid::Device device = item->device(); const bool setup = device.is<Solid::StorageAccess>() && !m_storageSetupInProgress.contains(device.as<Solid::StorageAccess>()) && !device.as<Solid::StorageAccess>()->isAccessible(); if (setup) { Solid::StorageAccess* access = device.as<Solid::StorageAccess>(); m_storageSetupInProgress[access] = index; connect(access, &Solid::StorageAccess::setupDone, this, &PlacesItemModel::slotStorageSetupDone); access->setup(); } }
bool K3b::mount( K3b::Device::Device* dev ) { if( !dev ) return false; QString mntDev = dev->blockDeviceName(); // first try to mount it the standard way if( KIO::NetAccess::synchronousRun( KIO::mount( true, QByteArray(), mntDev, QString() ), 0 ) ) return true; Solid::StorageAccess* sa = dev->solidStorage(); if ( sa && sa->setup() ) { return true; } // now try pmount QString pmountBin = K3b::findExe( "pmount" ); if( !pmountBin.isEmpty() ) { KProcess p; p << pmountBin; p << mntDev; p.start(); return p.waitForFinished(-1); } // and the most simple one QString mountBin = K3b::findExe( "mount" ); if( !mountBin.isEmpty() ) { KProcess p; p << mountBin; p << mntDev; p.start(); return p.waitForFinished(-1); } return false; }
void SolidHwTest::testSetupTeardown() { Solid::StorageAccess *access; { Solid::Device device("/org/kde/solid/fakehw/volume_part1_size_993284096"); access = device.as<Solid::StorageAccess>(); } QList<QVariant> args; QSignalSpy spy(access, SIGNAL(accessibilityChanged(bool,QString))); access->teardown(); QCOMPARE(spy.count(), 1); args = spy.takeFirst(); QCOMPARE(args.at(0).toBool(), false); access->setup(); QCOMPARE(spy.count(), 1); args = spy.takeFirst(); QCOMPARE(args.at(0).toBool(), true); }
void StorageDevice::mount() { Solid::StorageAccess *access = m_device.as<Solid::StorageAccess>(); access->setup(); }