From 008fce9421d4e59bf6be61995fd11397bd313e88 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 9 Nov 2008 14:56:02 +0000 Subject: [PATCH] Hack around the fact that CBR or CBZ documents can ahve the wrong extension. (And I wonder, if the only way to recognize them is via extension, wtf?) BUG: 174701 svn path=/trunk/KDE/kdegraphics/okular/; revision=882007 --- generators/comicbook/document.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generators/comicbook/document.cpp b/generators/comicbook/document.cpp index 42dab2a14..65992a16a 100644 --- a/generators/comicbook/document.cpp +++ b/generators/comicbook/document.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include "unrar.h" @@ -32,10 +33,12 @@ bool Document::open( const QString &fileName ) { close(); + const KMimeType::Ptr mime = KMimeType::findByFileContent( fileName ); + /** * We have a zip archive */ - if ( fileName.toLower().endsWith( ".cbz" ) ) { + if ( mime->is( "application/x-cbz" ) || mime->name() == "application/zip" ) { mZip = new KZip( fileName ); if ( !mZip->open( QIODevice::ReadOnly ) ) { @@ -66,7 +69,7 @@ bool Document::open( const QString &fileName ) extractImageFiles( entries ); - } else { + } if ( mime->is( "application/x-cbr" ) || mime->name() == "application/x-rar" ) { if ( !Unrar::isAvailable() ) { mLastErrorString = i18n( "Cannot open document, unrar was not found." ); return false; @@ -90,6 +93,9 @@ bool Document::open( const QString &fileName ) } extractImageFiles( mUnrar->list() ); + } else { + mLastErrorString = i18n( "Unknown ComickBook format." ); + return false; } return true;