also port the kio to the latest kchmviewer stuff

svn path=/trunk/KDE/kdegraphics/okular/; revision=770395
remotes/origin/KDE/4.1
Albert Astals Cid 18 years ago
parent d60620d33d
commit 302ffcc05b
  1. 1
      generators/chm/kio-msits/CMakeLists.txt
  2. 56
      generators/chm/kio-msits/msits.cpp
  3. 3
      generators/chm/kio-msits/msits.h

@ -1,5 +1,6 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../../..
${CMAKE_CURRENT_SOURCE_DIR}/../lib
${CHM_INCLUDE_DIR}
)

@ -19,18 +19,16 @@
#include <sys/stat.h>
#include <kapplication.h>
#include <kcomponentdata.h>
#include <kdebug.h>
#include <kurl.h>
#include <kmimetype.h>
#include <kio/udsentry.h>
#include <qfile.h>
#include <qbitarray.h>
#include <qvector.h>
#include "msits.h"
#include "libchmurlfactory.h"
using namespace KIO;
@ -80,8 +78,9 @@ static bool isDirectory ( const QString & filename )
void ProtocolMSITS::get( const KUrl& url )
{
QString fileName;
QString htmdata, fileName;
chmUnitInfo ui;
QByteArray buf;
kDebug() << "kio_msits::get() " << url.path();
@ -90,35 +89,43 @@ void ProtocolMSITS::get( const KUrl& url )
kDebug() << "kio_msits::get: parseLoadAndLookup returned " << fileName;
if ( isDirectory (fileName) )
if ( LCHMUrlFactory::handleFileType( url.path(), htmdata ) )
{
error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
return;
buf = htmdata.toUtf8();
kDebug() << "Using special handling for image pages: " << htmdata;
}
if ( !ResolveObject ( fileName, &ui) )
else
{
kDebug() << "kio_msits::get: could not resolve filename " << fileName;
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
return;
}
if ( isDirectory (fileName) )
{
error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
return;
}
QByteArray buf (ui.length, '\0');
if ( !ResolveObject ( fileName, &ui) )
{
kDebug() << "kio_msits::get: could not resolve filename " << fileName;
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
return;
}
if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
{
kDebug() << "kio_msits::get: could not retrieve filename " << fileName;
error( KIO::ERR_NO_CONTENT, url.prettyUrl() );
return;
buf.resize( ui.length );
if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
{
kDebug() << "kio_msits::get: could not retrieve filename " << fileName;
error( KIO::ERR_NO_CONTENT, url.prettyUrl() );
return;
}
}
totalSize( ui.length );
totalSize( buf.size() );
KMimeType::Ptr result = KMimeType::findByNameAndContent( fileName, buf );
kDebug() << "Emitting mimetype " << result->name();
mimeType( result->name() );
data( buf );
processedSize( ui.length );
processedSize( buf.size() );
finished();
}
@ -138,7 +145,11 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
QString filename = url.path().left (pos);
abspath = url.path().mid (pos + 2); // skip ::
// Some buggy apps add ms-its:/ to the path as well
if ( abspath.startsWith( "ms-its:" ) )
abspath = abspath.mid( 7 );
kDebug() << "ProtocolMSITS::parseLoadAndLookup: filename " << filename << ", path " << abspath;
if ( filename.isEmpty() )
@ -276,7 +287,6 @@ void ProtocolMSITS::listDir (const KUrl & url)
return;
}
// totalFiles(listing.size());
UDSEntry entry;
int striplength = filepath.length();

@ -22,7 +22,6 @@
#define MSITS_H
//#include <kio/global.h>
#include <kio/slavebase.h>
#include <kurl.h>
@ -52,7 +51,7 @@ private:
// Resolve an object inside a CHM file
inline bool ResolveObject (const QString& fileName, chmUnitInfo *ui)
{
return m_chmFile != NULL && ::chm_resolve_object(m_chmFile, fileName.toAscii().constData(), ui) == CHM_RESOLVE_SUCCESS;
return m_chmFile != NULL && ::chm_resolve_object(m_chmFile, fileName.toUtf8().constData(), ui) == CHM_RESOLVE_SUCCESS;
}
// Retrieve an object from the CHM file

Loading…
Cancel
Save