diff options
Diffstat (limited to 'tdeioslaves')
-rw-r--r-- | tdeioslaves/Makefile.am | 1 | ||||
-rw-r--r-- | tdeioslaves/videodvd/Makefile.am | 19 | ||||
-rw-r--r-- | tdeioslaves/videodvd/videodvd.cpp | 407 | ||||
-rw-r--r-- | tdeioslaves/videodvd/videodvd.desktop | 48 | ||||
-rw-r--r-- | tdeioslaves/videodvd/videodvd.h | 55 | ||||
-rw-r--r-- | tdeioslaves/videodvd/videodvd.protocol | 52 |
6 files changed, 582 insertions, 0 deletions
diff --git a/tdeioslaves/Makefile.am b/tdeioslaves/Makefile.am new file mode 100644 index 0000000..55ab08d --- /dev/null +++ b/tdeioslaves/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = videodvd diff --git a/tdeioslaves/videodvd/Makefile.am b/tdeioslaves/videodvd/Makefile.am new file mode 100644 index 0000000..c20e773 --- /dev/null +++ b/tdeioslaves/videodvd/Makefile.am @@ -0,0 +1,19 @@ +INCLUDES = -I$(srcdir)/../../libk3b/tools \ + -I$(srcdir)/../../libk3b/core \ + -I$(srcdir)/../../libk3bdevice \ + $(all_includes) + +kde_module_LTLIBRARIES = kio_videodvd.la + +kio_videodvd_la_SOURCES = videodvd.cpp +kio_videodvd_la_LIBADD = -lkio ../../libk3b/libk3b.la +kio_videodvd_la_LDFLAGS = -avoid-version -module $(all_libraries) $(KDE_PLUGIN) $(LIB_QT) -lkio -ltdecore -L../../libk3bdevice/.libs -lk3bdevice + +protocol_DATA = videodvd.protocol +protocoldir = $(kde_servicesdir) + +konq_sidebartree_init_services_data_DATA = videodvd.desktop +konq_sidebartree_init_services_datadir = $(kde_datadir)/konqsidebartng/virtual_folders/services + +messages: + $(XGETTEXT) *.cpp -o $(podir)/tdeio_videodvd.pot diff --git a/tdeioslaves/videodvd/videodvd.cpp b/tdeioslaves/videodvd/videodvd.cpp new file mode 100644 index 0000000..c3398a1 --- /dev/null +++ b/tdeioslaves/videodvd/videodvd.cpp @@ -0,0 +1,407 @@ +/* + * + * $Id: sourceheader 380067 2005-01-19 13:03:46Z trueg $ + * Copyright (C) 2005 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#include <config.h> + +#include <tqcstring.h> +#include <tqdatetime.h> +#include <tqbitarray.h> +#include <tqptrlist.h> + +#include <kdebug.h> +#include <kinstance.h> +#include <kglobal.h> +#include <klocale.h> +#include <kurl.h> + +#include <stdlib.h> + +#include <k3bdevicemanager.h> +#include <k3bdevice.h> +#include <k3biso9660.h> +#include <k3biso9660backend.h> +#include <k3b_export.h> + +#include "videodvd.h" + +using namespace TDEIO; + +extern "C" +{ + LIBK3B_EXPORT int kdemain( int argc, char **argv ) + { + TDEInstance instance( "kio_videodvd" ); + + kdDebug(7101) << "*** Starting kio_videodvd " << endl; + + if (argc != 4) + { + kdDebug(7101) << "Usage: kio_videodvd protocol domain-socket1 domain-socket2" << endl; + exit(-1); + } + + kio_videodvdProtocol slave(argv[2], argv[3]); + slave.dispatchLoop(); + + kdDebug(7101) << "*** kio_videodvd Done" << endl; + return 0; + } +} + + + +// FIXME: Does it really make sense to use a static device manager? Are all instances +// of videodvd started in another process? +K3bDevice::DeviceManager* kio_videodvdProtocol::s_deviceManager = 0; +int kio_videodvdProtocol::s_instanceCnt = 0; + +kio_videodvdProtocol::kio_videodvdProtocol(const TQCString &pool_socket, const TQCString &app_socket) + : SlaveBase("kio_videodvd", pool_socket, app_socket) +{ + kdDebug() << "kio_videodvdProtocol::kio_videodvdProtocol()" << endl; + if( !s_deviceManager ) + { + s_deviceManager = new K3bDevice::DeviceManager(); + s_deviceManager->setCheckWritingModes( false ); + s_deviceManager->scanBus(); + } + s_instanceCnt++; +} + + +kio_videodvdProtocol::~kio_videodvdProtocol() +{ + kdDebug() << "kio_videodvdProtocol::~kio_videodvdProtocol()" << endl; + s_instanceCnt--; + if( s_instanceCnt == 0 ) + { + delete s_deviceManager; + s_deviceManager = 0; + } +} + + +TDEIO::UDSEntry kio_videodvdProtocol::createUDSEntry( const K3bIso9660Entry* e ) const +{ + TDEIO::UDSEntry uds; + TDEIO::UDSAtom a; + + a.m_uds = TDEIO::UDS_NAME; + a.m_str = e->name(); + uds.append( a ); + + a.m_uds = TDEIO::UDS_ACCESS; + a.m_long = e->permissions(); + uds.append( a ); + + a.m_uds = TDEIO::UDS_CREATION_TIME; + a.m_long = e->date(); + uds.append( a ); + + a.m_uds = TDEIO::UDS_MODIFICATION_TIME; + a.m_long = e->date(); + uds.append( a ); + + if( e->isDirectory() ) + { + a.m_uds = TDEIO::UDS_FILE_TYPE; + a.m_long = S_IFDIR; + uds.append( a ); + + a.m_uds = TDEIO::UDS_MIME_TYPE; + a.m_str = "inode/directory"; + uds.append( a ); + } + else + { + const K3bIso9660File* file = static_cast<const K3bIso9660File*>( e ); + + a.m_uds = TDEIO::UDS_SIZE; + a.m_long = file->size(); + uds.append( a ); + + a.m_uds = TDEIO::UDS_FILE_TYPE; + a.m_long = S_IFREG; + uds.append( a ); + + a.m_uds = TDEIO::UDS_MIME_TYPE; + if( e->name().endsWith( "VOB" ) ) + a.m_str = "video/mpeg"; + else + a.m_str = "unknown"; + uds.append( a ); + } + + return uds; +} + + +// FIXME: remember the iso instance for quicker something and search for the videodvd +// in the available devices. +K3bIso9660* kio_videodvdProtocol::openIso( const KURL& url, TQString& plainIsoPath ) +{ + // get the volume id from the url + TQString volumeId = url.path().section( '/', 1, 1 ); + + kdDebug() << "(kio_videodvdProtocol) searching for Video dvd: " << volumeId << endl; + + // now search the devices for this volume id + // FIXME: use the cache created in listVideoDVDs + for( TQPtrListIterator<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. + // this time let K3bIso9660 decide if we need dvdcss or not + // FIXME: check for encryption and libdvdcss and report an error + if( di.isDvdMedia() && di.numTracks() == 1 ) { + K3bIso9660* iso = new K3bIso9660( dev ); + iso->setPlainIso9660( true ); + if( iso->open() && iso->primaryDescriptor().volumeId == volumeId ) { + plainIsoPath = url.path().section( "/", 2, -1 ) + "/"; + kdDebug() << "(kio_videodvdProtocol) using iso path: " << plainIsoPath << endl; + return iso; + } + delete iso; + } + } + + error( ERR_SLAVE_DEFINED, i18n("No VideoDVD found") ); + return 0; +} + + +void kio_videodvdProtocol::get(const KURL& url ) +{ + kdDebug() << "kio_videodvd::get(const KURL& url)" << endl ; + + TQString isoPath; + if( K3bIso9660* iso = openIso( url, isoPath ) ) + { + const K3bIso9660Entry* e = iso->firstIsoDirEntry()->entry( isoPath ); + if( e && e->isFile() ) + { + const K3bIso9660File* file = static_cast<const K3bIso9660File*>( e ); + totalSize( file->size() ); + TQByteArray buffer( 10*2048 ); + int read = 0; + int cnt = 0; + TDEIO::filesize_t totalRead = 0; + while( (read = file->read( totalRead, buffer.data(), buffer.size() )) > 0 ) + { + buffer.resize( read ); + data(buffer); + ++cnt; + totalRead += read; + if( cnt == 10 ) + { + cnt = 0; + processedSize( totalRead ); + } + } + + delete iso; + + data(TQByteArray()); // empty array means we're done sending the data + + if( read == 0 ) + finished(); + else + error( ERR_SLAVE_DEFINED, i18n("Read error.") ); + } + else + error( ERR_DOES_NOT_EXIST, url.path() ); + } +} + + +void kio_videodvdProtocol::listDir( const KURL& url ) +{ + if( url.path() == "/" ) { + listVideoDVDs(); + } + else { + TQString 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); + TQStringList el = dir->entries(); + el.remove( "." ); + el.remove( ".." ); + UDSEntryList udsl; + for( TQStringList::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; + } + } +} + + +void kio_videodvdProtocol::listVideoDVDs() +{ + int cnt = 0; + + for( TQPtrListIterator<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; + TDEIO::UDSEntry uds; + TDEIO::UDSAtom a; + + a.m_uds = TDEIO::UDS_NAME; + a.m_str = iso.primaryDescriptor().volumeId; + uds.append( a ); + + a.m_uds = TDEIO::UDS_FILE_TYPE; + a.m_long = S_IFDIR; + uds.append( a ); + + a.m_uds = TDEIO::UDS_MIME_TYPE; + a.m_str = "inode/directory"; + uds.append( a ); + + a.m_uds = TDEIO::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 kio_videodvdProtocol::stat( const KURL& url ) +{ + if( url.path() == "/" ) { + // + // stat the root path + // + TDEIO::UDSEntry uds; + TDEIO::UDSAtom a; + + a.m_uds = TDEIO::UDS_NAME; + a.m_str = "/"; + uds.append( a ); + + a.m_uds = TDEIO::UDS_FILE_TYPE; + a.m_long = S_IFDIR; + uds.append( a ); + + a.m_uds = TDEIO::UDS_MIME_TYPE; + a.m_str = "inode/directory"; + uds.append( a ); + + statEntry( uds ); + finished(); + } + else { + TQString 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; + } + } +} + + +// FIXME: when does this get called? It seems not to be used for the files. +void kio_videodvdProtocol::mimetype( const KURL& url ) +{ + if( url.path() == "/" ) { + error( ERR_UNSUPPORTED_ACTION, "mimetype(/)" ); + return; + } + + TQString isoPath; + K3bIso9660* iso = openIso( url, isoPath ); + if( iso ) + { + const K3bIso9660Entry* e = iso->firstIsoDirEntry()->entry( isoPath ); + if( e ) + { + if( e->isDirectory() ) + mimeType( "inode/directory" ); + else if( e->name().endsWith( ".VOB" ) ) + { + mimetype( "video/mpeg" ); + } + else + { + // send some data + const K3bIso9660File* file = static_cast<const K3bIso9660File*>( e ); + TQByteArray buffer( 10*2048 ); + int read = file->read( 0, buffer.data(), buffer.size() ); + if( read > 0 ) + { + buffer.resize( read ); + data(buffer); + data(TQByteArray()); + finished(); + // FIXME: do we need to emit finished() after emitting the end of data()? + } + else + error( ERR_SLAVE_DEFINED, i18n("Read error.") ); + } + } + delete iso; + } +} diff --git a/tdeioslaves/videodvd/videodvd.desktop b/tdeioslaves/videodvd/videodvd.desktop new file mode 100644 index 0000000..1454f40 --- /dev/null +++ b/tdeioslaves/videodvd/videodvd.desktop @@ -0,0 +1,48 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Link +URL=videodvd:/ +Icon=dvd_unmount +Name=Video DVD Browser +Name[af]=Video DVD Blaaier +Name[ar]= قارىء القرص المدمج المرئي الرقمي DVD +Name[bg]=Браузър за видео DVD +Name[br]=Furcher DVD Video +Name[ca]=Navegador de DVDs de vídeo +Name[cs]=Prohlížeč Video DVD +Name[da]=Video-dvd browser +Name[de]=Video-DVD-Browser +Name[el]=Περιηγητής Video DVD +Name[eo]=Videa DVD foliumilo +Name[es]=Navegador de DVD de vídeo +Name[et]=Video DVD sirvija +Name[fa]= مرورگر دی وی دی ویدئویی +Name[fi]=Video-dvd selain +Name[fr]=Navigateur de DVD +Name[gl]=Explorador de Vídeo DVD +Name[hu]=Video DVD-böngésző +Name[is]=Vídeó DVD flakkari +Name[it]=Navigatore DVD video +Name[ja]=ビデオ DVD ブラウザ +Name[ka]=ვიდეო DVD-ის ბროუზერი +Name[km]=កម្មវិធីរុករកឌីវីឌីវីដេអូ +Name[lt]=Video DVD naršyklė +Name[nds]=Video-DVD-Kieker +Name[nn]=Film-DVD-lesar +Name[pa]=ਵੀਡਿਓ DVD ਝਲਕਾਰਾ +Name[pl]=Przeglądarka płyt DVD Video +Name[pt]=Navegador de DVD de Vídeo +Name[pt_BR]=Navegador de DVD de Vídeo +Name[sk]=Video DVD prehliadač +Name[sr]=Прегледач видео DVD-а +Name[sr@Latn]=Pregledač video DVD-a +Name[sv]=Video-dvd bläddrare +Name[tr]=Görüntü DVD'si Gezgini +Name[uk]=Навігатор відео-DVD +Name[uz]=Video-DVD brauzeri +Name[uz@cyrillic]=Видео-DVD браузери +Name[zh_CN]=视频 DVD 浏览器 +Name[zh_TW]=Video DVD 瀏覽器 +Open=false +X-TDE-TreeModule=Directory +X-TDE-KonqSidebarModule=konqsidebar_tree diff --git a/tdeioslaves/videodvd/videodvd.h b/tdeioslaves/videodvd/videodvd.h new file mode 100644 index 0000000..3b02aff --- /dev/null +++ b/tdeioslaves/videodvd/videodvd.h @@ -0,0 +1,55 @@ +/* + * + * $Id: sourceheader 380067 2005-01-19 13:03:46Z trueg $ + * Copyright (C) 2005 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#ifndef _videodvd_H_ +#define _videodvd_H_ + +#include <tqstring.h> +#include <tqcstring.h> + +#include <kurl.h> +#include <tdeio/global.h> +#include <tdeio/slavebase.h> + +class TQCString; +class K3bIso9660Entry; +class K3bIso9660; +namespace K3bDevice +{ + class DeviceManager; +} + +class kio_videodvdProtocol : public TDEIO::SlaveBase +{ +public: + kio_videodvdProtocol(const TQCString &pool_socket, const TQCString &app_socket); + ~kio_videodvdProtocol(); + + void mimetype( const KURL& url ); + void stat( const KURL& url ); + void get( const KURL& url ); + void listDir( const KURL& url ); + +private: + K3bIso9660* openIso( const KURL&, TQString& plainIsoPath ); + TDEIO::UDSEntry createUDSEntry( const K3bIso9660Entry* e ) const; + void listVideoDVDs(); + + static K3bDevice::DeviceManager* s_deviceManager; + static int s_instanceCnt; +}; + +#endif diff --git a/tdeioslaves/videodvd/videodvd.protocol b/tdeioslaves/videodvd/videodvd.protocol new file mode 100644 index 0000000..7efaf10 --- /dev/null +++ b/tdeioslaves/videodvd/videodvd.protocol @@ -0,0 +1,52 @@ +[Protocol] +exec=kio_videodvd +protocol=videodvd +input=none +output=filesystem +reading=true +listing=Name,Type,Size,Date +Icon=dvd_unmount +Class=:local +Description=A tdeioslave that allows files to be copied from a Video DVD (including decryption) +Description[af]='n 'Kioslave' wat jou toelaat om lêers vanaf 'n Video DVD te kopiëer. Dit doen ook die nodige dekripsie. +Description[ar]= يسمح هذا ال-tdeioslave بنسخ الملفات من قرص مدمج مرئي رقمي DVD ( بما فيه فك التشفير ) +Description[bg]=tdeioslave, позволяващ ви да копирате файлове от видео DVD (включително разшифроването) +Description[bn]=একটি কে-আই-ও স্লেভ যেটি একটি ভিডিও ডিভিডি থেকে ফাইল কপি করতে অনুমতিদেয় (ডিক্রিপশন সহ) +Description[ca]=Un tdeioslave que permet que es copiïn fitxers des d'un DVD de vídeo (incloent el desxifrat) +Description[cs]=Kioslave umožňující kopírování video DVD (včetně dekódování) +Description[da]=En tdeioslave som gør det muligt at kopiere filer fra en video-dvd (inklusive afkodning) +Description[de]=Ein-/Ausgabemodul, mit dem man Dateien von einer Video-DVD kopieren kann (inkl. Entschlüsselung) +Description[el]=Ένα tdeioslave που επιτρέπει την αντιγραφή αρχείων από ένα DVD βίντεο (δυνατότητα αποκρυπτογράφησης) +Description[eo]=Kioslave kiu permesas kopii dosierojn el videa DVD (inklude malĉifro) +Description[es]=Un tdeioslave que permite copiar archivos de un DVD de vídeo (incluye descifrado) +Description[et]=KIO-moodul, mis võimaldab kopeerida faile video DVD-lt (vajadusel dekrüpteerib) +Description[fa]=یک tdeioslave که اجازه میدهد پروندهها از یک دی وی دی ویدئویی )شامل سرگشایی( رونوشت شوند +Description[fi]=Kioslave-palvelu, joka mahdollistaa tiedostojen purkamisen dvd-levyltä. +Description[fr]=Un tdeioslave qui permet de copier des fichiers depuis un DVD Vidéo (incluant le déchiffrement) +Description[gl]=Un tdeioslave que permite copiar ficheiros dun Video DVD (incluindo descifrar) +Description[he]=עבד קלט/פלט של KDE המאפשר לקבצים להיות מועתקים מתקליטור וידאו של DVD (כולל פענוח) +Description[hu]=Kioslave, amellyel fájlokat lehet másolni Video DVD-ről (dekódolással együtt) +Description[is]=Kioslave sem leyfir afritun af skrám frá vídeó DVD (með afkóðun) +Description[it]=Un tdeioslave che permette ai file di essere copiati da un DVD video (incluso decifrazione) +Description[ja]=ビデオ DVD からファイルをコピーすることを可能にする tdeioslave (暗号解除も含む) +Description[ka]=Kioslave, რომელიც იძლევა Video DVD-დან ასლის ფაილების მიღების საშუელებას (გაშიფრვასთან ერთად) +Description[km]=tdeioslave ដែលអនុញ្ញាតឲ្យចម្លងឯកសារពីឌីវីឌីវីដេអូ(រួមទាំងការឌិគ្រីប) +Description[lt]=Priedas (tdeioslave) leidžiantis kopijuoti bylas iš Video DVD (taip pat ir atšifruoti) +Description[ms]=tdeioslave yang membenarkan fail untuk disalin dari DVD Video (termasuk nyahenkripsi) +Description[nb]=En tdeioslave som gjør det mulig å kopiere filer fra en Video-DVD (medregnet dekryptering) +Description[nds]=En In-/Utgaavmoduul, mit dat sik Dateien vun en Video-DVD koperen laat (ok mit Opslöteln) +Description[nl]=Een tdeioslave waarmee u bestanden van een video-dvd kunt kopiëren (inclusief versleuteling) +Description[nn]=Ein tdeioslave som gjer det mogleg å kopiera filer frå ein film-DVD (inkludert kryptering) +Description[pa]=ਇੱਕ tdeioslave ਹੈ, ਜੋ ਕਿ ਫਾਇਲਾਂ ਨੂੰ ਇੱਕ DVD (ਡਿਸਕਰਿਪਸ਼ਨ ਸਮੇ) ਤੋਂ ਨਕਲ ਕਰਨ ਲਈ ਸਹਾਇਕ ਹੈ +Description[pl]=Wtyczka protokołu pozwalająca kopiować pliki z płyt DVD Video (łącznie z odszyfrowywaniem) +Description[pt]=Um 'tdeioslave' que permite copiar ficheiros de um DVD Vídeo (incluindo decifrar) +Description[pt_BR]=Um tdeioslave que permite que arquivos sejam copiados de um DVD de Vídeo (incluindo a quebra da proteção) +Description[ru]=Позволяет копировать файлы с Video DVD (с дешифровкой) +Description[sk]=tdeioslave, ktorý umožňuje kopírovať súbory z Video DVD (vrátane dešifrovania) +Description[sr]=tdeioslave који омогућава копирање фајлова са видео DVD-а (укључујући дешифровање) +Description[sr@Latn]=tdeioslave koji omogućava kopiranje fajlova sa video DVD-a (uključujući dešifrovanje) +Description[sv]=En I/O-slav som gör det möjligt att kopiera filer från en video-dvd (inklusive avkodning) +Description[tr]= Bir Görüntü DVD'sinden dosyaların kopyalanmasını (ve kodunun çözülmesini) sağlayan tdeioslave +Description[uk]=Підлеглий В/В, який дає змогу копіювати файли з Відео DVD (включаючи розшифрування) +Description[zh_CN]=允许从视频 DVD(包括加密影碟)中复制文件的 tdeioslave +Description[zh_TW]=允許直接從 Video DVD 複製檔案的 tdeioslave(會自動解密) |