void kio_videodvdProtocol::listVideoDVDs() { int cnt = 0; for( QPtrListIterator<K3bDevice::Device> it( s_deviceManager->dvdReader() ); *it; ++it ) { K3bDevice::Device* dev = *it; K3bDevice::DiskInfo di = dev->diskInfo(); // we search for a DVD with a single track. if( di.isDvdMedia() && di.numTracks() == 1 ) { // // now do a quick check for VideoDVD. // - no dvdcss for speed // - only a check for the VIDEO_TS dir // K3bIso9660 iso( new K3bIso9660DeviceBackend(dev) ); iso.setPlainIso9660( true ); if( iso.open() && iso.firstIsoDirEntry()->entry( "VIDEO_TS" ) ) { // FIXME: cache the entry for speedup UDSEntryList udsl; KIO::UDSEntry uds; KIO::UDSAtom a; a.m_uds = KIO::UDS_NAME; a.m_str = iso.primaryDescriptor().volumeId; uds.append( a ); a.m_uds = KIO::UDS_FILE_TYPE; a.m_long = S_IFDIR; uds.append( a ); a.m_uds = KIO::UDS_MIME_TYPE; a.m_str = "inode/directory"; uds.append( a ); a.m_uds = KIO::UDS_ICON_NAME; a.m_str = "dvd_unmount"; uds.append( a ); udsl.append( uds ); listEntries( udsl ); ++cnt; } } } if( cnt ) finished(); else error( ERR_SLAVE_DEFINED, i18n("No VideoDVD found") ); }
void SieveJob::slotEntries( Job *, const UDSEntryList & l ) { // loop over entries: for ( UDSEntryList::const_iterator it = l.begin() ; it != l.end() ; ++it ) { // Loop over all UDS atoms to find the UDSEntry::UDS_ACCESS and UDS_NAME atoms; // note if we find an exec'able file ( == active script ) // or the requested filename (mUrl.fileName()). const QString filename = it->stringValue( KIO::UDSEntry::UDS_NAME ); mAvailableScripts.append( filename ); bool isActive = ( it->numberValue( KIO::UDSEntry::UDS_ACCESS ) == 0700 ); if ( isActive ) mActiveScriptName = filename; if ( mFileExists == DontKnow && filename == mUrl.fileName() ) mFileExists = Yes; emit item( this, filename, isActive ); if ( mFileExists == Yes && !mActiveScriptName.isEmpty() ) return; // early return if we have all information } }
void kio_videodvdProtocol::listDir( const KURL& url ) { if( url.path() == "/" ) { listVideoDVDs(); } else { QString isoPath; K3bIso9660* iso = openIso( url, isoPath ); if( iso ) { const K3bIso9660Directory* mainDir = iso->firstIsoDirEntry(); const K3bIso9660Entry* e = mainDir->entry( isoPath ); if( e ) { if( e->isDirectory() ) { const K3bIso9660Directory* dir = static_cast<const K3bIso9660Directory*>(e); QStringList el = dir->entries(); el.remove( "." ); el.remove( ".." ); UDSEntryList udsl; for( QStringList::const_iterator it = el.begin(); it != el.end(); ++it ) udsl.append( createUDSEntry( dir->entry( *it ) ) ); listEntries( udsl ); finished(); } else { error( ERR_CANNOT_ENTER_DIRECTORY, url.path() ); } } else { error( ERR_CANNOT_ENTER_DIRECTORY, url.path() ); } // for testing we always do the whole thing delete iso; } } }
bool SlaveInterface::dispatch(int _cmd, const QByteArray &rawdata) { Q_D(SlaveInterface); //kDebug(7007) << "dispatch " << _cmd; QDataStream stream(rawdata); QString str1; qint32 i; qint8 b; quint32 ul; switch(_cmd) { case MSG_DATA: emit data(rawdata); break; case MSG_DATA_REQ: emit dataReq(); break; case MSG_OPENED: emit open(); break; case MSG_FINISHED: //kDebug(7007) << "Finished [this = " << this << "]"; d->offset = 0; d->speed_timer.stop(); emit finished(); break; case MSG_STAT_ENTRY: { UDSEntry entry; stream >> entry; emit statEntry(entry); break; } case MSG_LIST_ENTRIES: { quint32 count; stream >> count; UDSEntryList list; UDSEntry entry; for (uint i = 0; i < count; i++) { stream >> entry; list.append(entry); } emit listEntries(list); break; } case MSG_RESUME: { // From the put job d->offset = readFilesize_t(stream); emit canResume(d->offset); break; } case MSG_CANRESUME: // From the get job d->filesize = d->offset; emit canResume(0); // the arg doesn't matter break; case MSG_ERROR: stream >> i >> str1; kDebug(7007) << "error " << i << " " << str1; emit error(i, str1); break; case MSG_SLAVE_STATUS: { PIDType<sizeof(pid_t)>::PID_t stream_pid; pid_t pid; QByteArray protocol; stream >> stream_pid >> protocol >> str1 >> b; pid = stream_pid; emit slaveStatus(pid, protocol, str1, (b != 0)); break; } case MSG_CONNECTED: emit connected(); break; case MSG_WRITTEN: { KIO::filesize_t size = readFilesize_t(stream); emit written(size); break; } case INF_TOTAL_SIZE: { KIO::filesize_t size = readFilesize_t(stream); gettimeofday(&d->start_time, 0); d->last_time = 0; d->filesize = d->offset; d->sizes[0] = d->filesize - d->offset; d->times[0] = 0; d->nums = 1; d->speed_timer.start(1000); d->slave_calcs_speed = false; emit totalSize(size); break; } case INF_PROCESSED_SIZE: { KIO::filesize_t size = readFilesize_t(stream); emit processedSize( size ); d->filesize = size; break; } case INF_POSITION: { KIO::filesize_t pos = readFilesize_t(stream); emit position(pos); break; } case INF_SPEED: stream >> ul; d->slave_calcs_speed = true; d->speed_timer.stop(); emit speed( ul ); break; case INF_GETTING_FILE: break; case INF_ERROR_PAGE: emit errorPage(); break; case INF_REDIRECTION: { KUrl url; stream >> url; emit redirection( url ); break; } case INF_MIME_TYPE: stream >> str1; emit mimeType(str1); if (!d->connection->suspended()) d->connection->sendnow(CMD_NONE, QByteArray()); break; case INF_WARNING: stream >> str1; emit warning(str1); break; case INF_MESSAGEBOX: { kDebug(7007) << "needs a msg box"; QString text, caption, buttonYes, buttonNo, dontAskAgainName; int type; stream >> type >> text >> caption >> buttonYes >> buttonNo; if (stream.atEnd()) { messageBox(type, text, caption, buttonYes, buttonNo); } else { stream >> dontAskAgainName; messageBox(type, text, caption, buttonYes, buttonNo, dontAskAgainName); } break; } case INF_INFOMESSAGE: { QString msg; stream >> msg; emit infoMessage(msg); break; } case INF_META_DATA: { MetaData m; stream >> m; if (m.contains(QLatin1String("ssl_in_use"))) { const QLatin1String ssl_("ssl_"); const MetaData constM = m; for (MetaData::ConstIterator it = constM.lowerBound(ssl_); it != constM.constEnd(); ++it) { if (it.key().startsWith(ssl_)) { d->sslMetaData.insert(it.key(), it.value()); } else { // we're past the ssl_* entries; remember that QMap is ordered. break; } } } emit metaData(m); break; } case MSG_NET_REQUEST: { QString host; QString slaveid; stream >> host >> slaveid; requestNetwork(host, slaveid); break; } case MSG_NET_DROP: { QString host; QString slaveid; stream >> host >> slaveid; dropNetwork(host, slaveid); break; } case MSG_NEED_SUBURL_DATA: { emit needSubUrlData(); break; } case MSG_HOST_INFO_REQ: { QString hostName; stream >> hostName; HostInfo::lookupHost(hostName, this, SLOT(slotHostInfo(QHostInfo))); break; } default: kWarning(7007) << "Slave sends unknown command (" << _cmd << "), dropping slave"; return false; } return true; }