Exemple #1
0
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") );
}
Exemple #2
0
KIO::UDSEntry kio_videodvdProtocol::createUDSEntry( const K3bIso9660Entry* e ) const
{
  KIO::UDSEntry uds;
  KIO::UDSAtom a;

  a.m_uds = KIO::UDS_NAME;
  a.m_str = e->name();
  uds.append( a );

  a.m_uds = KIO::UDS_ACCESS;
  a.m_long = e->permissions();
  uds.append( a );

  a.m_uds = KIO::UDS_CREATION_TIME;
  a.m_long = e->date();
  uds.append( a );

  a.m_uds = KIO::UDS_MODIFICATION_TIME;
  a.m_long = e->date();
  uds.append( a );

  if( e->isDirectory() )
  {
    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 );
  }
  else
  {
    const K3bIso9660File* file = static_cast<const K3bIso9660File*>( e );

    a.m_uds = KIO::UDS_SIZE;
    a.m_long = file->size();
    uds.append( a );

    a.m_uds = KIO::UDS_FILE_TYPE;
    a.m_long = S_IFREG;
    uds.append( a );

    a.m_uds = KIO::UDS_MIME_TYPE;
    if( e->name().endsWith( "VOB" ) )
      a.m_str = "video/mpeg";
    else
      a.m_str = "unknown";
    uds.append( a );
  }

  return uds;
}
Exemple #3
0
KIO::UDSEntry HomeImpl::extractUrlInfos(const KURL &url)
{
	m_entryBuffer.clear();

	KIO::StatJob *job = KIO::stat(url, false);
	connect( job, SIGNAL( result(KIO::Job *) ),
	         this, SLOT( slotStatResult(KIO::Job *) ) );
	qApp->eventLoop()->enterLoop();

	KIO::UDSEntry::iterator it = m_entryBuffer.begin();
	KIO::UDSEntry::iterator end = m_entryBuffer.end();

	KIO::UDSEntry infos;

	for(; it!=end; ++it)
	{
		switch( (*it).m_uds )
		{
		case KIO::UDS_ACCESS:
		case KIO::UDS_USER:
		case KIO::UDS_GROUP:
		case KIO::UDS_CREATION_TIME:
		case KIO::UDS_MODIFICATION_TIME:
		case KIO::UDS_ACCESS_TIME:
			infos.append(*it);
			break;
		default:
			break;
		}
	}
	
	addAtom(infos, KIO::UDS_LOCAL_PATH, 0, url.path());

	return infos;
}
Exemple #4
0
static void addAtom(KIO::UDSEntry &entry, unsigned int ID, long long l, const QString &s = QString::null)
{
    KIO::UDSAtom atom;
    atom.m_uds = ID;
    atom.m_long = l;
    atom.m_str = s;
    entry.append(atom);
}
Exemple #5
0
void PakProtocol::createUDSEntry(const KArchiveEntry *archiveEntry, KIO::UDSEntry &entry) {
	KIO::UDSAtom atom;
	entry.clear();

	atom.m_uds = KIO::UDS_NAME;
	atom.m_str = remoteEncoding()->decode(archiveEntry->name().local8Bit());
	entry.append(atom);

	atom.m_uds = KIO::UDS_SIZE;
	atom.m_long = archiveEntry->isFile() ? ((KArchiveFile *)archiveEntry)->size() : 0L ;
	entry.append(atom);

	atom.m_uds = KIO::UDS_FILE_TYPE;
	atom.m_long = archiveEntry->permissions() & S_IFMT; // keep file type only
	entry.append(atom);

	atom.m_uds = KIO::UDS_ACCESS;
	atom.m_long = archiveEntry->permissions() & 07777; // keep permissions only
	entry.append(atom);
}
Exemple #6
0
void kio_videodvdProtocol::stat( const KURL& url )
{
  if( url.path() == "/" ) {
    //
    // stat the root path
    //
    KIO::UDSEntry uds;
    KIO::UDSAtom a;
    
    a.m_uds = KIO::UDS_NAME;
    a.m_str = "/";
    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 );

    statEntry( uds );
    finished();
  }
  else {
    QString isoPath;
    K3bIso9660* iso = openIso( url, isoPath );
    if( iso ) {
      const K3bIso9660Entry* e = iso->firstIsoDirEntry()->entry( isoPath );
      if( e ) {
	statEntry( createUDSEntry( e ) );
	finished();
      }
      else
	error( ERR_DOES_NOT_EXIST, url.path() );
      
      delete iso;
    }
  }
}
Exemple #7
0
KIO::UDSEntry MediaImpl::extractUrlInfos(const KURL &url)
{
    m_entryBuffer.clear();

    KIO::StatJob *job = KIO::stat(url, false);
    job->setAutoWarningHandlingEnabled(false);
    connect(job, SIGNAL(result(KIO::Job *)), this, SLOT(slotStatResult(KIO::Job *)));
    connect(job, SIGNAL(warning(KIO::Job *, const QString &)), this, SLOT(slotWarning(KIO::Job *, const QString &)));
    qApp->eventLoop()->enterLoop();

    KIO::UDSEntry::iterator it = m_entryBuffer.begin();
    KIO::UDSEntry::iterator end = m_entryBuffer.end();

    KIO::UDSEntry infos;

    for(; it != end; ++it)
    {
        switch((*it).m_uds)
        {
            case KIO::UDS_ACCESS:
            case KIO::UDS_USER:
            case KIO::UDS_GROUP:
            case KIO::UDS_CREATION_TIME:
            case KIO::UDS_MODIFICATION_TIME:
            case KIO::UDS_ACCESS_TIME:
                infos.append(*it);
                break;
            default:
                break;
        }
    }

    if(url.isLocalFile())
    {
        addAtom(infos, KIO::UDS_LOCAL_PATH, 0, url.path());
    }

    return infos;
}
Exemple #8
0
void PakProtocol::stat(const KURL &url) {
	kdDebug(PAK_DEBUG_ID) << "Entering stat()" << endl;
	QString path;
	KIO::UDSEntry entry;
	KIO::Error errorNum;
	if ( !checkNewFile( url, path, errorNum ) )
	{
		// We may be looking at a real directory - this happens
		// when pressing up after being in the root of an archive
		if ( errorNum == KIO::ERR_CANNOT_OPEN_FOR_READING )
		{
			// If we cannot open, it might be a problem with the archive header (e.g. unsupported format)
			// Therefore give a more specific error message
			error( KIO::ERR_SLAVE_DEFINED,
					i18n( "Could not open the file, probably due to an unsupported file format.\n%1")
					.arg( url.prettyURL() ) );
			return;
		}
		else if ( errorNum != KIO::ERR_IS_DIRECTORY )
		{
			// We have any other error
			error( errorNum, url.prettyURL() );
			return;
		}
		// Real directory. Return just enough information for KRun to work
		KIO::UDSAtom atom;
		atom.m_uds = KIO::UDS_NAME;
		atom.m_str = url.fileName();
		entry.append( atom );
		kdDebug( PAK_DEBUG_ID ) << "ArchiveProtocol::stat returning name=" << url.fileName() << endl;

		KDE_struct_stat buff;
		if ( KDE_stat( QFile::encodeName( url.path() ), &buff ) == -1 )
		{
			// Should not happen, as the file was already stated by checkNewFile
			error( KIO::ERR_COULD_NOT_STAT, url.prettyURL() );
			return;
		}

		atom.m_uds = KIO::UDS_FILE_TYPE;
		atom.m_long = buff.st_mode & S_IFMT;
		entry.append( atom );

		statEntry( entry );

		finished();

		// And let go of the tar file - for people who want to unmount a cdrom after that
		delete _pakFile;
		_pakFile = 0L;
		return;
	}

	const KArchiveDirectory* root = _pakFile->directory();
	const KArchiveEntry* archiveEntry;
	if ( path.isEmpty() )
	{
		path = QString::fromLatin1( "/" );
		archiveEntry = root;
	} else {
		path = QString::fromLocal8Bit(remoteEncoding()->encode(path));
		archiveEntry = root->entry( path );
	}
	if ( !archiveEntry )
	{
		error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
		return;
	}

	createUDSEntry( archiveEntry, entry );
	statEntry( entry );

	finished();

	/*kdDebug(PAK_DEBUG_ID) << "Entering stat()" << endl;
	KIO::UDSEntry entry;
	createUDSEntry(NULL, entry);
	kdDebug(PAK_DEBUG_ID) << "Giving file away" << endl;
	statEntry(entry);
	finished();
	kdDebug(PAK_DEBUG_ID) << "-<> Exiting stat()" << endl;*/
}