From 605ae18b99fe55b19b854a4d54bc4fb9c7827147 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Sun, 9 Nov 2008 18:13:04 +0000 Subject: [PATCH 01/48] Initial import of mobipocket generator svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882081 --- CMakeLists.txt | 41 ++++++ Messages.sh | 2 + TODO | 7 + converter.cpp | 50 +++++++ converter.h | 30 +++++ generator_mobi.cpp | 37 +++++ generator_mobi.h | 20 +++ libokularGenerator_mobi.desktop | 10 ++ mobidocument.cpp | 65 +++++++++ mobidocument.h | 40 ++++++ mobipocket.cpp | 230 ++++++++++++++++++++++++++++++++ mobipocket.h | 51 +++++++ okularApplication_mobi.desktop | 54 ++++++++ okularMobi.desktop | 8 ++ x-mobipocket.xml | 8 ++ 15 files changed, 653 insertions(+) create mode 100644 CMakeLists.txt create mode 100755 Messages.sh create mode 100644 TODO create mode 100644 converter.cpp create mode 100644 converter.h create mode 100644 generator_mobi.cpp create mode 100644 generator_mobi.h create mode 100644 libokularGenerator_mobi.desktop create mode 100644 mobidocument.cpp create mode 100644 mobidocument.h create mode 100644 mobipocket.cpp create mode 100644 mobipocket.h create mode 100644 okularApplication_mobi.desktop create mode 100644 okularMobi.desktop create mode 100644 x-mobipocket.xml diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..878961d02 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +CMAKE_MINIMUM_REQUIRED( VERSION 2.6 ) + + +project(okular-mobi-generator) + +ENABLE_TESTING() + +find_package(KDE4 REQUIRED) +include_directories(${KDE4_INCLUDES} ${QT_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +########### next target ############### + +find_package(SharedMimeInfo REQUIRED) + + +set(okularGenerator_mobi_PART_SRCS + converter.cpp + mobipocket.cpp + mobidocument.cpp + generator_mobi.cpp +) + +kde4_add_plugin(okularGenerator_mobi ${okularGenerator_mobi_PART_SRCS}) + +target_link_libraries(okularGenerator_mobi okularcore ${mobi_LIBRARIES} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) + +install(TARGETS okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) + + +########### install files ############### + +install( FILES libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES okularApplication_mobi.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) + +install( + FILES x-mobipocket.xml + DESTINATION ${XDG_MIME_INSTALL_DIR} +) +update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR}) diff --git a/Messages.sh b/Messages.sh new file mode 100755 index 000000000..48b9406a4 --- /dev/null +++ b/Messages.sh @@ -0,0 +1,2 @@ +#!/bin/sh +$XGETTEXT $(find . -name "*.cpp") -o $podir/okular_mobi.pot diff --git a/TODO b/TODO new file mode 100644 index 000000000..2945cb4b9 --- /dev/null +++ b/TODO @@ -0,0 +1,7 @@ +- images are broken in some files +- better error handling +- tests for Mobipocket classes +- anchors (a filepos=) +- handle files compression with Huffman encoding +- decryption for DRMed files + diff --git a/converter.cpp b/converter.cpp new file mode 100644 index 000000000..b019aafef --- /dev/null +++ b/converter.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#include "converter.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace Mobi; + +Converter::Converter() +{ + +} + +Converter::~Converter() +{ +} + + +QTextDocument* Converter::convert( const QString &fileName ) +{ + MobiDocument* newDocument=new MobiDocument(fileName); + if (!newDocument->isValid()) { + emit error(i18n("Error while opening the EPub document."), -1); + delete newDocument; + return NULL; + } + newDocument->setPageSize(QSizeF(600, 800)); + + QTextFrameFormat frameFormat; + frameFormat.setMargin( 20 ); + QTextFrame *rootFrame = newDocument->rootFrame(); + rootFrame->setFrameFormat( frameFormat ); + return newDocument; +} diff --git a/converter.h b/converter.h new file mode 100644 index 000000000..cc60e8d0c --- /dev/null +++ b/converter.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ +#ifndef MOBI_CONVERTER_H +#define MOBI_CONVERTER_H + +#include +#include + +#include "mobidocument.h" + +class QTextCursor; + +namespace Mobi { + class Converter : public Okular::TextDocumentConverter + { + public: + Converter(); + ~Converter(); + + virtual QTextDocument *convert( const QString &fileName ); + }; +} + +#endif diff --git a/generator_mobi.cpp b/generator_mobi.cpp new file mode 100644 index 000000000..950dea77e --- /dev/null +++ b/generator_mobi.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ely Levy * + * * + * 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. * + ***************************************************************************/ +#include "generator_mobi.h" + +#include "converter.h" + +#include + +static KAboutData createAboutData() +{ + KAboutData aboutData( + "okular_epub", + "okular_epub", + ki18n("Mobipocket Backend"), + "0.1", + ki18n("An mobipocket backend"), + KAboutData::License_GPL, + ki18n("© 2008 Jakub Stachowski") + ); + aboutData.addAuthor(ki18n("Jakub Stachowski"), KLocalizedString(), + "qbast@go2.pl"); + + return aboutData; +} + +OKULAR_EXPORT_PLUGIN( MobiGenerator, createAboutData() ) + +MobiGenerator::MobiGenerator( QObject *parent, const QVariantList &args ) +: Okular::TextDocumentGenerator( new Mobi::Converter, parent, args ) +{ +} diff --git a/generator_mobi.h b/generator_mobi.h new file mode 100644 index 000000000..94b3cf3bd --- /dev/null +++ b/generator_mobi.h @@ -0,0 +1,20 @@ +/*************************************************************************** + * Copyright (C) 2008 by Ely Levy * + * * + * 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. * + ***************************************************************************/ +#ifndef _OKULAR_GENERATOR_MOBI_H_ +#define _OKULAR_GENERATOR_MOBI_H_ +#include + +class MobiGenerator : public Okular::TextDocumentGenerator +{ + public: + MobiGenerator( QObject *parent, const QVariantList &args ); + ~MobiGenerator() {} +}; + +#endif diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop new file mode 100644 index 000000000..c9d97a6a5 --- /dev/null +++ b/libokularGenerator_mobi.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Service +Name=Mobipocket document +Comment=Mobipocket backend for Okular +X-KDE-ServiceTypes=okular/Generator +MimeType=application/x-mobipocket; +X-KDE-Library=okularGenerator_mobi +X-KDE-Priority=1 +X-KDE-okularAPIVersion=1 +X-KDE-okularHasInternalSettings=false diff --git a/mobidocument.cpp b/mobidocument.cpp new file mode 100644 index 000000000..9b5c6b5bb --- /dev/null +++ b/mobidocument.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ +#include "mobidocument.h" +#include "qmobi.h" +#include +#include +#include + +using namespace Mobi; + +MobiDocument::MobiDocument(const QString &fileName) : QTextDocument() +{ + file = new QFile(fileName); + file->open(QIODevice::ReadOnly); + doc = new Mobipocket::Document(file); + if (doc->isValid()) setHtml(fixMobiMarkup(doc->text())); +} + +bool MobiDocument::isValid() const +{ + return doc->isValid(); +} + +MobiDocument::~MobiDocument() +{ + delete doc; + delete file; +} + +QVariant MobiDocument::loadResource(int type, const QUrl &name) +{ + + kDebug() << "Requested resource: " << type << " URL " << name; + + if (type!=QTextDocument::ImageResource || name.scheme()!=QString("pdbrec")) return QVariant(); + bool ok; + quint16 recnum=name.path().mid(1).toUShort(&ok); + kDebug() << "Path" << name.path().mid(1) << " Img " << recnum << " all imgs " << doc->imageCount(); + if (!ok || recnum>=doc->imageCount()) return QVariant(); + + QVariant resource; + resource.setValue(doc->getImage(recnum)); + addResource(type, name, resource); + + return resource; +} + + +QString MobiDocument::fixMobiMarkup(const QString& data) +{ + QRegExp imgs("<[iI][mM][gG].*recindex=\"([0-9]*)\".*>"); + + imgs.setMinimal(true); + QString ret=data; + ret.replace(imgs,""); + ret.replace("","

"); + //FIXME: anchors + return ret; +} diff --git a/mobidocument.h b/mobidocument.h new file mode 100644 index 000000000..a6442ff5c --- /dev/null +++ b/mobidocument.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ +#ifndef MOBI_DOCUMENT_H +#define MOBI_DOCUMENT_H + +#include +#include +#include + +class QFile; +namespace Mobipocket { +class Document; +} + +namespace Mobi { + + class MobiDocument : public QTextDocument { + + public: + MobiDocument(const QString &fileName); + bool isValid() const; + ~MobiDocument(); + + protected: + virtual QVariant loadResource(int type, const QUrl &name); + + private: + QString fixMobiMarkup(const QString& data); + Mobipocket::Document *doc; + QFile* file; + }; + +} +#endif diff --git a/mobipocket.cpp b/mobipocket.cpp new file mode 100644 index 000000000..b8b737aaf --- /dev/null +++ b/mobipocket.cpp @@ -0,0 +1,230 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * RLE decompressor based on FBReader * + * Copyright (C) 2004-2008 Geometer Plus * + * * + * 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. * + ***************************************************************************/ + +#include +#include +#include +#include +#include + +static unsigned char TOKEN_CODE[256] = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, +}; + +namespace Mobipocket { + +class NOOPDecompressor : public Decompressor +{ +public: + QByteArray decompress(const QByteArray& data) { return data; } +}; + + +class RLEDecompressor : public Decompressor +{ +public: + QByteArray decompress(const QByteArray& data); +}; + +QByteArray RLEDecompressor::decompress(const QByteArray& data) +{ + QByteArray ret; + ret.reserve(8192); + + unsigned char token; + unsigned short copyLength, N, shift; + unsigned short shifted; + int i=0; + int maxIndex=data.size()-1; + + while (i maxIndex) ) { + goto endOfLoop; + } + ret.append(data.mid(i,token)); + i+=token; + break; + case 2: + ret.append(' '); + ret.append(token ^ 0x80); + break; + case 3: + if (i + 1 > maxIndex) { + goto endOfLoop; + } +// N = (token << 8) + data.at(i++); + N = token; + N<<=8; + N+=(unsigned char)data.at(i++); + copyLength = (N & 7) + 3; + shift = (N & 0x3fff) / 8; + shifted = ret.size()-shift; + if (shifted>(ret.size()-1)) goto endOfLoop; + for (int i=0;i recordOffsets; + QIODevice* device; + QString fileType; + QString name; + quint16 nrecords; + bool valid; + + void init(); +}; + +void PDBPrivate::init() +{ + valid=true; + quint16 word; + quint32 dword; + device->seek(0); + name=QString::fromLatin1(device->read(32)); + device->seek(0x3c); + fileType=QString::fromLatin1(device->read(8)); + + device->seek(0x4c); + device->read((char*)&word,2); + nrecords=qFromBigEndian(word); + + for (int i=0;iread((char*)&dword,4); + recordOffsets.append(qFromBigEndian(dword)); + device->read((char*)&dword,4); + } +} + +PDB::PDB(QIODevice* dev) : d(new PDBPrivate) +{ + d->device=dev; + d->init(); +} + +QByteArray PDB::getRecord(int i) const +{ + if (i>=d->nrecords) return QByteArray(); + quint32 offset=d->recordOffsets[i]; + bool last=(i==(d->nrecords-1)); + quint32 size=0; + if (last) size=d->device->size()-offset; + else size=d->recordOffsets[i+1]-offset; + d->device->seek(offset); + return d->device->read(size); +} + +QString PDB::name() const +{ + return d->name; +} + +bool PDB::isValid() const +{ + return d->valid; +} + +int PDB::recordCount() const +{ + return d->nrecords; +} + +//////////////////////////////////////////// +struct DocumentPrivate +{ + DocumentPrivate(QIODevice* d) : pdb(d), valid(true) {} + PDB pdb; + Decompressor* dec; + quint16 ntextrecords; + bool valid; + + void init() { + valid=pdb.isValid(); + if (!valid) return; + QByteArray mhead=pdb.getRecord(0); + if (mhead[0]!=(char)0) {} + + switch (mhead[1]) { + case 1 : dec = new NOOPDecompressor(); break; + case 2 : dec = new RLEDecompressor(); break; + default : dec=0; {} + } + ntextrecords=(unsigned char)mhead[8]; + ntextrecords<<=8; + ntextrecords+=(unsigned char)mhead[9]; + } +}; + +Document::Document(QIODevice* dev) : d(new DocumentPrivate(dev)) +{ + d->init(); +} + +QString Document::text() const +{ + QByteArray whole; + for (int i=1;intextrecords;i++) + whole+=d->dec->decompress(d->pdb.getRecord(i)); + return QString::fromUtf8(whole); +} + +int Document::imageCount() const +{ + //FIXME: don't count FLIS and FCIS records + return d->pdb.recordCount()-d->ntextrecords; +} + +bool Document::isValid() const +{ + return d->pdb.isValid(); +} + +QImage Document::getImage(int i) const +{ + QByteArray rec=d->pdb.getRecord(d->ntextrecords+i); + kDebug() << "Want IMG " << i; + kDebug() << rec[0] << rec[1] << rec[2] << rec[3]; + //FIXME: check if i is in range + return QImage::fromData(rec); +} +} diff --git a/mobipocket.h b/mobipocket.h new file mode 100644 index 000000000..94f77a66b --- /dev/null +++ b/mobipocket.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#include +#include +#include +#include + +class QIODevice; + +namespace Mobipocket { + +struct PDBPrivate; + +class PDB { +public: + PDB(QIODevice* dev); + QString fileType() const; + int recordCount() const; + QByteArray getRecord(int i) const; + QString name() const; + bool isValid() const; +private: + PDBPrivate* const d; +}; + +class Decompressor { +public: + virtual QByteArray decompress(const QByteArray& data) = 0; + virtual ~Decompressor() {} +}; + +struct DocumentPrivate; +class Document { +public: + Document(QIODevice* dev); + QMap metadata() const; + QString text() const; + int imageCount() const; + QImage getImage(int i) const; + bool isValid() const; +private: + DocumentPrivate* const d; +}; +} diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop new file mode 100644 index 000000000..c9840e73d --- /dev/null +++ b/okularApplication_mobi.desktop @@ -0,0 +1,54 @@ +[Desktop Entry] +MimeType=application/x-mobipocket; +Terminal=false +Name=Okular +Name[x-test]=xxOkularxx +GenericName=Document Viewer +GenericName[bg]=Визуализатор +GenericName[ca]=Visualitzador de documents +GenericName[cs]=Prohlížeč dokumentů +GenericName[da]=Dokumentfremviser +GenericName[de]=Dokumentenbetrachter +GenericName[el]=Προβολέας εγγράφων +GenericName[eo]=Dokumenta rigardilo +GenericName[es]=Visor de documentos +GenericName[et]=Dokumendinäitaja +GenericName[fa]=مشاهده‌گر سند +GenericName[fi]=Asiakirjan näyttöohjelma +GenericName[fr]=Visionneuse de document +GenericName[ga]=Amharcán Cáipéisí +GenericName[gl]=Visor de documentos +GenericName[hi]=दस्तावेज़ प्रदर्शक +GenericName[hu]=Dokumentumnézegető +GenericName[is]=Skjalaskoðari +GenericName[it]=Visore di documenti +GenericName[ja]=文書ビューア +GenericName[kk]=Құжатты қарау +GenericName[km]=កម្មវិធី​មើល​ឯកសារ +GenericName[ko]=문서 뷰어 +GenericName[lv]=Dokumentu skatītājs +GenericName[nb]=Dokumentviser +GenericName[nds]=Dokmentkieker +GenericName[ne]=कागजात दर्शक +GenericName[nl]=Documentenviewer +GenericName[nn]=Dokumentvisar +GenericName[oc]=Visualizaire de documents +GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ +GenericName[pl]=Przeglądarka dokumentów +GenericName[pt]=Visualizador de Documentos +GenericName[pt_BR]=Visualizador de documentos +GenericName[ru]=Просмотр документов +GenericName[sl]=Pregledovalnik dokumentov +GenericName[sv]=Dokumentvisare +GenericName[th]=เครื่องมือแสดงเอกสาร +GenericName[tr]=Belge Gösterici +GenericName[uk]=Переглядач документів +GenericName[x-test]=xxDocument Viewerxx +GenericName[zh_CN]=文档查看器 +GenericName[zh_TW]=文件檢視器 +Exec=okular %U %i -caption "%c" +Icon=okular +Type=Application +InitialPreference=1 +Categories=Qt;KDE;Graphics;Viewer; +NoDisplay=true diff --git a/okularMobi.desktop b/okularMobi.desktop new file mode 100644 index 000000000..3d772eff6 --- /dev/null +++ b/okularMobi.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Icon=okular +Name=Okular +Name[x-test]=xxOkularxx +X-KDE-ServiceTypes=KParts/ReadOnlyPart +X-KDE-Library=okularpart +Type=Service +MimeType=application/x-mobipocket; diff --git a/x-mobipocket.xml b/x-mobipocket.xml new file mode 100644 index 000000000..aa7316687 --- /dev/null +++ b/x-mobipocket.xml @@ -0,0 +1,8 @@ + + + + Mobipocket document + + + + From 8452972d08fb30003ea1af19b9c1ced24b57e528 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Sun, 9 Nov 2008 18:58:36 +0000 Subject: [PATCH 02/48] Search for first image instead of assuming that it is contained in record directly after text. svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882090 --- TODO | 3 +-- mobipocket.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 2945cb4b9..e9f9a05f7 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ -- images are broken in some files - better error handling - tests for Mobipocket classes - anchors (a filepos=) - handle files compression with Huffman encoding - decryption for DRMed files - +- metadata diff --git a/mobipocket.cpp b/mobipocket.cpp index b8b737aaf..32fba2866 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include static unsigned char TOKEN_CODE[256] = { @@ -172,11 +173,12 @@ int PDB::recordCount() const //////////////////////////////////////////// struct DocumentPrivate { - DocumentPrivate(QIODevice* d) : pdb(d), valid(true) {} + DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0) {} PDB pdb; Decompressor* dec; quint16 ntextrecords; bool valid; + quint16 firstImageRecord; void init() { valid=pdb.isValid(); @@ -193,6 +195,18 @@ struct DocumentPrivate ntextrecords<<=8; ntextrecords+=(unsigned char)mhead[9]; } + void findFirstImage() { + firstImageRecord=ntextrecords+1; + while (firstImageRecordpdb.getRecord(d->ntextrecords+i); - kDebug() << "Want IMG " << i; - kDebug() << rec[0] << rec[1] << rec[2] << rec[3]; + if (!d->firstImageRecord) d->findFirstImage(); + QByteArray rec=d->pdb.getRecord(d->firstImageRecord+i-1); //FIXME: check if i is in range return QImage::fromData(rec); } From 81f027ec30ba87d46c0d51c674b17a94abf20e0c Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 12:20:53 +0000 Subject: [PATCH 03/48] Support for files compressed with Huffman encoding. This means you can finally read some files that FBReader cannot handle svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882322 --- CMakeLists.txt | 2 +- TODO | 1 - converter.cpp | 4 +- decompressor.cpp | 236 +++++++++++++++++++++++++++++++++++++++++++++++ decompressor.h | 29 ++++++ mobipocket.cpp | 117 ++++------------------- mobipocket.h | 6 -- test.cpp | 13 +++ 8 files changed, 300 insertions(+), 108 deletions(-) create mode 100644 decompressor.cpp create mode 100644 decompressor.h create mode 100644 test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 878961d02..7e7a290f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ find_package(SharedMimeInfo REQUIRED) set(okularGenerator_mobi_PART_SRCS converter.cpp mobipocket.cpp + decompressor.cpp mobidocument.cpp generator_mobi.cpp ) @@ -28,7 +29,6 @@ target_link_libraries(okularGenerator_mobi okularcore ${mobi_LIBRARIES} ${KDE4_K install(TARGETS okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) - ########### install files ############### install( FILES libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/TODO b/TODO index e9f9a05f7..f8dadf39f 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,5 @@ - better error handling - tests for Mobipocket classes - anchors (a filepos=) -- handle files compression with Huffman encoding - decryption for DRMed files - metadata diff --git a/converter.cpp b/converter.cpp index b019aafef..e4df55227 100644 --- a/converter.cpp +++ b/converter.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ QTextDocument* Converter::convert( const QString &fileName ) { MobiDocument* newDocument=new MobiDocument(fileName); if (!newDocument->isValid()) { - emit error(i18n("Error while opening the EPub document."), -1); + emit error(i18n("Error while opening the Mobipocket document."), -1); delete newDocument; return NULL; } diff --git a/decompressor.cpp b/decompressor.cpp new file mode 100644 index 000000000..b63c796d3 --- /dev/null +++ b/decompressor.cpp @@ -0,0 +1,236 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * RLE decompressor based on FBReader * + * Copyright (C) 2004-2008 Geometer Plus * + * * + * Huffdic decompressor based on Python code by Igor Skochinsky * + * * + * 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. * + ***************************************************************************/ + +#include "mobipocket.h" +#include "decompressor.h" + +#include + +static unsigned char TOKEN_CODE[256] = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, +}; + +namespace Mobipocket { + +class NOOPDecompressor : public Decompressor +{ +public: + NOOPDecompressor(const PDB& p) : Decompressor(p) {} + QByteArray decompress(const QByteArray& data) { return data; } +}; + + +class RLEDecompressor : public Decompressor +{ +public: + RLEDecompressor(const PDB& p) : Decompressor(p) {} + QByteArray decompress(const QByteArray& data); +}; + +class BitReader +{ +public: + BitReader(const QByteArray& d) : pos(0), data(d) + { + data.append("\000\000\000\000"); + len=data.size()*8; + } + + quint32 read() { + quint32 g=0; + quint64 r=0; + while (g<32) { + r=(r << 8) | (quint8)data[(pos+g)>>3]; + g=g+8 - ((pos+g) & 7); + } + return (r >> (g-32)); + } + bool eat(int n) { + pos+=n; + return pos <= len; + } + + int left() { + return len - pos; + } + +private: + int pos; + int len; + QByteArray data; +}; + +class HuffdicDecompressor : public Decompressor +{ +public: + HuffdicDecompressor(const PDB& p); + QByteArray decompress(const QByteArray& data); +private: + void unpack(BitReader reader, int depth = 0); + QList dicts; + quint32 entry_bits; + quint32 dict1[256]; + quint32 dict2[64]; + + QByteArray buf; +}; + + + +QByteArray RLEDecompressor::decompress(const QByteArray& data) +{ + QByteArray ret; + ret.reserve(8192); + + unsigned char token; + unsigned short copyLength, N, shift; + unsigned short shifted; + int i=0; + int maxIndex=data.size()-1; + + while (i maxIndex) ) { + goto endOfLoop; + } + ret.append(data.mid(i,token)); + i+=token; + break; + case 2: + ret.append(' '); + ret.append(token ^ 0x80); + break; + case 3: + if (i + 1 > maxIndex) { + goto endOfLoop; + } + N = token; + N<<=8; + N+=(unsigned char)data.at(i++); + copyLength = (N & 7) + 3; + shift = (N & 0x3fff) / 8; + shifted = ret.size()-shift; + if (shifted>(ret.size()-1)) goto endOfLoop; + for (int i=0;i32) goto fail; + while (reader.left()) { + quint32 dw=reader.read(); + quint32 v=dict1[dw>>24]; + quint8 codelen = v & 0x1F; + if (!codelen) goto fail; + quint32 code = dw >> (32 - codelen); + quint32 r=(v >> 8); + if (!( v & 0x80)) { + while (code < dict2[(codelen-1)*2]) { + codelen++; + code = dw >> (32 - codelen); + } + r = dict2[(codelen-1)*2+1]; + } + r-=code; + if (!codelen) goto fail; + if (!reader.eat(codelen)) return; + quint32 dict_no = r >> entry_bits; + quint32 off1 = 16 + (r - (dict_no << entry_bits))*2; + QByteArray dict=dicts[dict_no]; + quint32 off2 = 16 + (unsigned char)dict[off1]*256 + (unsigned char)dict[off1+1]; + quint32 blen = (unsigned char)dict[off2]*256 + (unsigned char)dict[off2+1]; + QByteArray slice=dict.mid(off2+2,(blen & 0x7fff)); + if (blen & 0x8000) buf+=slice; + else unpack(BitReader(slice),depth+1); + } + return; +fail: + valid=false; +} + +Decompressor* Decompressor::create(quint8 type, const PDB& pdb) +{ + switch (type) { + case 1 : return new NOOPDecompressor(pdb); + case 2 : return new RLEDecompressor(pdb); + case 'H' : return new HuffdicDecompressor(pdb); + default : return 0; + } + +} +} diff --git a/decompressor.h b/decompressor.h new file mode 100644 index 000000000..2509c72df --- /dev/null +++ b/decompressor.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#include +namespace Mobipocket { + +class PDB; + +class Decompressor { +public: + Decompressor(const PDB& p) : pdb(p), valid(true) {} + virtual QByteArray decompress(const QByteArray& data) = 0; + virtual ~Decompressor() {} + bool isValid() const { return valid; } + + static Decompressor* create(quint8 type, const PDB& pdb); +protected: + const PDB& pdb; + bool valid; +}; + + +} \ No newline at end of file diff --git a/mobipocket.cpp b/mobipocket.cpp index 32fba2866..8e9fd08f8 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -1,110 +1,23 @@ /*************************************************************************** * Copyright (C) 2008 by Jakub Stachowski * * * - * RLE decompressor based on FBReader * - * Copyright (C) 2004-2008 Geometer Plus * - * * * 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. * ***************************************************************************/ -#include +#include "mobipocket.h" +#include "decompressor.h" + #include #include #include #include #include -static unsigned char TOKEN_CODE[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; - namespace Mobipocket { -class NOOPDecompressor : public Decompressor -{ -public: - QByteArray decompress(const QByteArray& data) { return data; } -}; - - -class RLEDecompressor : public Decompressor -{ -public: - QByteArray decompress(const QByteArray& data); -}; - -QByteArray RLEDecompressor::decompress(const QByteArray& data) -{ - QByteArray ret; - ret.reserve(8192); - - unsigned char token; - unsigned short copyLength, N, shift; - unsigned short shifted; - int i=0; - int maxIndex=data.size()-1; - - while (i maxIndex) ) { - goto endOfLoop; - } - ret.append(data.mid(i,token)); - i+=token; - break; - case 2: - ret.append(' '); - ret.append(token ^ 0x80); - break; - case 3: - if (i + 1 > maxIndex) { - goto endOfLoop; - } -// N = (token << 8) + data.at(i++); - N = token; - N<<=8; - N+=(unsigned char)data.at(i++); - copyLength = (N & 7) + 3; - shift = (N & 0x3fff) / 8; - shifted = ret.size()-shift; - if (shifted>(ret.size()-1)) goto endOfLoop; - for (int i=0;i recordOffsets; QIODevice* device; @@ -184,16 +97,19 @@ struct DocumentPrivate valid=pdb.isValid(); if (!valid) return; QByteArray mhead=pdb.getRecord(0); - if (mhead[0]!=(char)0) {} - - switch (mhead[1]) { - case 1 : dec = new NOOPDecompressor(); break; - case 2 : dec = new RLEDecompressor(); break; - default : dec=0; {} - } + kDebug() << "MHEAD" << (int)mhead[0]; +// if (mhead[0]!=(char)0) goto fail; + + kDebug() << "MHEAD" << (int)mhead[1]; + dec = Decompressor::create(mhead[1], pdb); + if (!dec) goto fail; ntextrecords=(unsigned char)mhead[8]; ntextrecords<<=8; ntextrecords+=(unsigned char)mhead[9]; + return; + fail: + valid=false; + } void findFirstImage() { firstImageRecord=ntextrecords+1; @@ -217,8 +133,13 @@ Document::Document(QIODevice* dev) : d(new DocumentPrivate(dev)) QString Document::text() const { QByteArray whole; - for (int i=1;intextrecords;i++) + for (int i=1;intextrecords+1;i++) { whole+=d->dec->decompress(d->pdb.getRecord(i)); + if (!d->dec->isValid()) { + d->valid=false; + return QString::null; + } + } return QString::fromUtf8(whole); } diff --git a/mobipocket.h b/mobipocket.h index 94f77a66b..5891c2db8 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -30,12 +30,6 @@ private: PDBPrivate* const d; }; -class Decompressor { -public: - virtual QByteArray decompress(const QByteArray& data) = 0; - virtual ~Decompressor() {} -}; - struct DocumentPrivate; class Document { public: diff --git a/test.cpp b/test.cpp new file mode 100644 index 000000000..0d2b7d540 --- /dev/null +++ b/test.cpp @@ -0,0 +1,13 @@ +#include "mobipocket.h" +#include +#include + +int main(int argc, char ** argv) +{ + QFile f(argv[1]); + f.open(QIODevice::ReadOnly); + Mobipocket::Document* d=new Mobipocket::Document(&f); + kDebug() << d->isValid(); + d->text(); + return 0; +} From ad86a49e7811c1ef8030e7171ee7c141c79a69a5 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 15:21:12 +0000 Subject: [PATCH 04/48] Handle metadata stored in EXTH header svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882348 --- converter.cpp | 16 ++++++++ converter.h | 3 ++ decompressor.h | 8 +++- mobidocument.cpp | 2 +- mobidocument.h | 2 + mobipocket.cpp | 98 +++++++++++++++++++++++++++++++++++------------- mobipocket.h | 7 +++- test.cpp | 13 ------- 8 files changed, 106 insertions(+), 43 deletions(-) delete mode 100644 test.cpp diff --git a/converter.cpp b/converter.cpp index e4df55227..d26d3e878 100644 --- a/converter.cpp +++ b/converter.cpp @@ -31,6 +31,20 @@ Converter::~Converter() { } +void Converter::handleMetadata(const QMap metadata) +{ + QMapIterator it(metadata); + while (it.hasNext()) { + it.next(); + switch (it.key()) { + case Mobipocket::Document::Title: addMetaData(Okular::DocumentInfo::Title, it.value()); break; + case Mobipocket::Document::Author: addMetaData(Okular::DocumentInfo::Author, it.value()); break; + case Mobipocket::Document::Description: addMetaData(Okular::DocumentInfo::Description, it.value()); break; + case Mobipocket::Document::Subject: addMetaData(Okular::DocumentInfo::Subject, it.value()); break; + case Mobipocket::Document::Copyright: addMetaData(Okular::DocumentInfo::Copyright, it.value()); break; + } + } +} QTextDocument* Converter::convert( const QString &fileName ) { @@ -40,6 +54,8 @@ QTextDocument* Converter::convert( const QString &fileName ) delete newDocument; return NULL; } + + handleMetadata(newDocument->mobi()->metadata()); newDocument->setPageSize(QSizeF(600, 800)); QTextFrameFormat frameFormat; diff --git a/converter.h b/converter.h index cc60e8d0c..1ee9d1c93 100644 --- a/converter.h +++ b/converter.h @@ -13,6 +13,7 @@ #include #include "mobidocument.h" +#include "mobipocket.h" class QTextCursor; @@ -24,6 +25,8 @@ namespace Mobi { ~Converter(); virtual QTextDocument *convert( const QString &fileName ); + private: + void handleMetadata(const QMap metadata); }; } diff --git a/decompressor.h b/decompressor.h index 2509c72df..a72f27d4c 100644 --- a/decompressor.h +++ b/decompressor.h @@ -7,6 +7,9 @@ * (at your option) any later version. * ***************************************************************************/ +#ifndef MOBI_DECOMPRESSOR_H +#define MOBI_DECOMPRESSOR_H + #include namespace Mobipocket { @@ -25,5 +28,6 @@ protected: bool valid; }; - -} \ No newline at end of file +quint32 readBELong(const QByteArray& data, int offset); +} +#endif diff --git a/mobidocument.cpp b/mobidocument.cpp index 9b5c6b5bb..d87dcb08f 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -7,7 +7,7 @@ * (at your option) any later version. * ***************************************************************************/ #include "mobidocument.h" -#include "qmobi.h" +#include "mobipocket.h" #include #include #include diff --git a/mobidocument.h b/mobidocument.h index a6442ff5c..e62e0d526 100644 --- a/mobidocument.h +++ b/mobidocument.h @@ -27,6 +27,8 @@ namespace Mobi { bool isValid() const; ~MobiDocument(); + Mobipocket::Document* mobi() const { return doc; } + protected: virtual QVariant loadResource(int type, const QUrl &name); diff --git a/mobipocket.cpp b/mobipocket.cpp index 8e9fd08f8..ac87ba6c3 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -92,38 +92,78 @@ struct DocumentPrivate quint16 ntextrecords; bool valid; quint16 firstImageRecord; + QMap metadata; - void init() { - valid=pdb.isValid(); - if (!valid) return; - QByteArray mhead=pdb.getRecord(0); - kDebug() << "MHEAD" << (int)mhead[0]; -// if (mhead[0]!=(char)0) goto fail; + void init(); + void findFirstImage(); + void parseEXTH(const QByteArray& data); + QString readEXTHRecord(const QByteArray& data, quint32& offset); + +}; - kDebug() << "MHEAD" << (int)mhead[1]; - dec = Decompressor::create(mhead[1], pdb); - if (!dec) goto fail; - ntextrecords=(unsigned char)mhead[8]; - ntextrecords<<=8; - ntextrecords+=(unsigned char)mhead[9]; - return; - fail: - valid=false; +void DocumentPrivate::init() +{ + valid=pdb.isValid(); + if (!valid) return; + QByteArray mhead=pdb.getRecord(0); + dec = Decompressor::create(mhead[1], pdb); + if (!dec) goto fail; + ntextrecords=(unsigned char)mhead[8]; + ntextrecords<<=8; + ntextrecords+=(unsigned char)mhead[9]; + if (mhead.size()>176) parseEXTH(mhead); + return; +fail: + valid=false; +} +void DocumentPrivate::findFirstImage() { + firstImageRecord=ntextrecords+1; + while (firstImageRecord Document::metadata() const +{ + return d->metadata; +} + } diff --git a/mobipocket.h b/mobipocket.h index 5891c2db8..aff903494 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -7,6 +7,9 @@ * (at your option) any later version. * ***************************************************************************/ +#ifndef MOBIPOCKET_H +#define MOBIPOCKET_H + #include #include #include @@ -33,8 +36,9 @@ private: struct DocumentPrivate; class Document { public: + enum MetaKey { Title, Author, Copyright, Description, Subject }; Document(QIODevice* dev); - QMap metadata() const; + QMap metadata() const; QString text() const; int imageCount() const; QImage getImage(int i) const; @@ -43,3 +47,4 @@ private: DocumentPrivate* const d; }; } +#endif diff --git a/test.cpp b/test.cpp deleted file mode 100644 index 0d2b7d540..000000000 --- a/test.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "mobipocket.h" -#include -#include - -int main(int argc, char ** argv) -{ - QFile f(argv[1]); - f.open(QIODevice::ReadOnly); - Mobipocket::Document* d=new Mobipocket::Document(&f); - kDebug() << d->isValid(); - d->text(); - return 0; -} From 26584743d0efbcb45ca0626dac2283eb7481de8d Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 15:39:47 +0000 Subject: [PATCH 05/48] Handle character encoding svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882351 --- mobipocket.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/mobipocket.cpp b/mobipocket.cpp index ac87ba6c3..ae7bc3e7b 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -86,35 +86,44 @@ int PDB::recordCount() const //////////////////////////////////////////// struct DocumentPrivate { - DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0) {} + DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false) {} PDB pdb; Decompressor* dec; quint16 ntextrecords; bool valid; quint16 firstImageRecord; QMap metadata; + bool isUtf; void init(); void findFirstImage(); void parseEXTH(const QByteArray& data); QString readEXTHRecord(const QByteArray& data, quint32& offset); + QString decodeString(const QByteArray& data) const; }; +QString DocumentPrivate::decodeString(const QByteArray& data) const +{ + return isUtf ? QString::fromUtf8(data) : QString::fromLatin1(data); +} + void DocumentPrivate::init() { valid=pdb.isValid(); if (!valid) return; QByteArray mhead=pdb.getRecord(0); dec = Decompressor::create(mhead[1], pdb); - if (!dec) goto fail; + if (!dec) { + valid=false; + return; + } ntextrecords=(unsigned char)mhead[8]; ntextrecords<<=8; ntextrecords+=(unsigned char)mhead[9]; + quint32 encoding=readBELong(mhead, 28); + if (encoding==65001) isUtf=true; if (mhead.size()>176) parseEXTH(mhead); - return; -fail: - valid=false; } void DocumentPrivate::findFirstImage() { @@ -135,7 +144,7 @@ QString DocumentPrivate::readEXTHRecord(const QByteArray& data, quint32& offset) quint32 len=readBELong(data,offset); offset+=4; len-=8; - QString ret=QString::fromUtf8(data.mid(offset,len)); + QString ret=decodeString(data.mid(offset,len)); offset+=len; return ret; } @@ -144,7 +153,7 @@ void DocumentPrivate::parseEXTH(const QByteArray& data) { quint32 nameoffset=readBELong(data,84); quint32 namelen=readBELong(data,88); - metadata[Document::Title]=QString::fromUtf8(data.mid(nameoffset, namelen)); + metadata[Document::Title]=decodeString(data.mid(nameoffset, namelen)); quint32 exthoffs=readBELong(data,20)+16; if (data.mid(exthoffs,4)!="EXTH") return; @@ -180,7 +189,7 @@ QString Document::text() const return QString::null; } } - return QString::fromUtf8(whole); + return d->decodeString(whole); } int Document::imageCount() const From 2e816b3970c60fc89c22488057ee3ffc3b6c23d0 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 19:54:41 +0000 Subject: [PATCH 06/48] Handle metadata for files without EXTH header svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882452 --- TODO | 3 +-- mobipocket.cpp | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index f8dadf39f..77eb436a4 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ - better error handling - tests for Mobipocket classes - anchors (a filepos=) -- decryption for DRMed files -- metadata +- decryption for DRMed files (may be impossible and/or illegal) diff --git a/mobipocket.cpp b/mobipocket.cpp index ae7bc3e7b..38eee3dcd 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -98,6 +98,7 @@ struct DocumentPrivate void init(); void findFirstImage(); void parseEXTH(const QByteArray& data); + void parseHtmlHead(const QString& data); QString readEXTHRecord(const QByteArray& data, quint32& offset); QString decodeString(const QByteArray& data) const; @@ -108,6 +109,28 @@ QString DocumentPrivate::decodeString(const QByteArray& data) const return isUtf ? QString::fromUtf8(data) : QString::fromLatin1(data); } +void DocumentPrivate::parseHtmlHead(const QString& data) +{ + static QRegExp title("(.*)", Qt::CaseInsensitive); + static QRegExp author("(.*)", Qt::CaseInsensitive); + static QRegExp copyright("(.*)", Qt::CaseInsensitive); + static QRegExp subject("(.*)", Qt::CaseInsensitive); + static QRegExp description("(.*)", Qt::CaseInsensitive); + title.setMinimal(true); + author.setMinimal(true); + copyright.setMinimal(true); + subject.setMinimal(true); + description.setMinimal(true); + + // title could have been already taken from MOBI record + if (!metadata.contains(Document::Title) && title.indexIn(data)!=-1) metadata[Document::Title]=title.capturedTexts()[1]; + if (author.indexIn(data)!=-1) metadata[Document::Author]=author.capturedTexts()[1]; + if (copyright.indexIn(data)!=-1) metadata[Document::Copyright]=copyright.capturedTexts()[1]; + if (subject.indexIn(data)!=-1) metadata[Document::Subject]=subject.capturedTexts()[1]; + if (description.indexIn(data)!=-1) metadata[Document::Description]=description.capturedTexts()[1]; + +} + void DocumentPrivate::init() { valid=pdb.isValid(); @@ -124,6 +147,9 @@ void DocumentPrivate::init() quint32 encoding=readBELong(mhead, 28); if (encoding==65001) isUtf=true; if (mhead.size()>176) parseEXTH(mhead); + + // try getting metadata from HTML if nothing or only title was recovered from MOBI and EXTH records + if (metadata.size()<2) parseHtmlHead(decodeString(dec->decompress(pdb.getRecord(1)))); } void DocumentPrivate::findFirstImage() { @@ -151,9 +177,15 @@ QString DocumentPrivate::readEXTHRecord(const QByteArray& data, quint32& offset) void DocumentPrivate::parseEXTH(const QByteArray& data) { - quint32 nameoffset=readBELong(data,84); - quint32 namelen=readBELong(data,88); - metadata[Document::Title]=decodeString(data.mid(nameoffset, namelen)); + // try to get name + if (data.size()>=92) { + quint32 nameoffset=readBELong(data,84); + quint32 namelen=readBELong(data,88); + if ( (nameoffset + namelen) < data.size() ) { + metadata[Document::Title]=decodeString(data.mid(nameoffset, namelen)); + } + } + quint32 exthoffs=readBELong(data,20)+16; if (data.mid(exthoffs,4)!="EXTH") return; From 66281019d4af7f8158996dffe1e2621cabd7baeb Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 20:59:55 +0000 Subject: [PATCH 07/48] Detect DRMed files and show error instead of mangled content svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882506 --- converter.cpp | 5 +++-- mobidocument.cpp | 5 ----- mobidocument.h | 1 - mobipocket.cpp | 13 ++++++++++--- mobipocket.h | 3 +++ 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/converter.cpp b/converter.cpp index d26d3e878..39a9a2124 100644 --- a/converter.cpp +++ b/converter.cpp @@ -49,8 +49,9 @@ void Converter::handleMetadata(const QMap QTextDocument* Converter::convert( const QString &fileName ) { MobiDocument* newDocument=new MobiDocument(fileName); - if (!newDocument->isValid()) { - emit error(i18n("Error while opening the Mobipocket document."), -1); + if (!newDocument->mobi()->isValid()) { + if (newDocument->mobi()->hasDRM()) emit error(i18n("This book is protected by DRM and can be displayed only on designated device"), -1); + else emit error(i18n("Error while opening the Mobipocket document."), -1); delete newDocument; return NULL; } diff --git a/mobidocument.cpp b/mobidocument.cpp index d87dcb08f..7affc2626 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -22,11 +22,6 @@ MobiDocument::MobiDocument(const QString &fileName) : QTextDocument() if (doc->isValid()) setHtml(fixMobiMarkup(doc->text())); } -bool MobiDocument::isValid() const -{ - return doc->isValid(); -} - MobiDocument::~MobiDocument() { delete doc; diff --git a/mobidocument.h b/mobidocument.h index e62e0d526..47b8328a0 100644 --- a/mobidocument.h +++ b/mobidocument.h @@ -24,7 +24,6 @@ namespace Mobi { public: MobiDocument(const QString &fileName); - bool isValid() const; ~MobiDocument(); Mobipocket::Document* mobi() const { return doc; } diff --git a/mobipocket.cpp b/mobipocket.cpp index 38eee3dcd..0d8e009c5 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -86,7 +86,7 @@ int PDB::recordCount() const //////////////////////////////////////////// struct DocumentPrivate { - DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false) {} + DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), drm(false) {} PDB pdb; Decompressor* dec; quint16 ntextrecords; @@ -94,6 +94,7 @@ struct DocumentPrivate quint16 firstImageRecord; QMap metadata; bool isUtf; + bool drm; void init(); void findFirstImage(); @@ -137,7 +138,8 @@ void DocumentPrivate::init() if (!valid) return; QByteArray mhead=pdb.getRecord(0); dec = Decompressor::create(mhead[1], pdb); - if (!dec) { + if ((int)mhead[12]!=0 || (int)mhead[13]!=0) drm=true; + if (!dec || drm) { valid=false; return; } @@ -232,7 +234,7 @@ int Document::imageCount() const bool Document::isValid() const { - return d->pdb.isValid(); + return d->valid; } QImage Document::getImage(int i) const @@ -248,4 +250,9 @@ QMap Document::metadata() const return d->metadata; } +bool Document::hasDRM() const +{ + return d->drm; +} + } diff --git a/mobipocket.h b/mobipocket.h index aff903494..ea2a408a3 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -43,6 +43,9 @@ public: int imageCount() const; QImage getImage(int i) const; bool isValid() const; + + // if true then isValid() will return false + bool hasDRM() const; private: DocumentPrivate* const d; }; From 9260931bbd00bd2b023929c6005f6ce047a2a43e Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 10 Nov 2008 21:29:07 +0000 Subject: [PATCH 08/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882539 --- okularApplication_mobi.desktop | 37 ++++++---------------------------- okularMobi.desktop | 1 + 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index c9840e73d..80af39885 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -2,50 +2,25 @@ MimeType=application/x-mobipocket; Terminal=false Name=Okular +Name[hi]=ऑकुलर Name[x-test]=xxOkularxx GenericName=Document Viewer -GenericName[bg]=Визуализатор -GenericName[ca]=Visualitzador de documents -GenericName[cs]=Prohlížeč dokumentů -GenericName[da]=Dokumentfremviser -GenericName[de]=Dokumentenbetrachter -GenericName[el]=Προβολέας εγγράφων -GenericName[eo]=Dokumenta rigardilo +GenericName[el]=Προβολέας εγγράφου GenericName[es]=Visor de documentos GenericName[et]=Dokumendinäitaja -GenericName[fa]=مشاهده‌گر سند -GenericName[fi]=Asiakirjan näyttöohjelma -GenericName[fr]=Visionneuse de document +GenericName[fr]=Visionneur de document GenericName[ga]=Amharcán Cáipéisí -GenericName[gl]=Visor de documentos +GenericName[gl]=Visor de documentos GenericName[hi]=दस्तावेज़ प्रदर्शक -GenericName[hu]=Dokumentumnézegető -GenericName[is]=Skjalaskoðari -GenericName[it]=Visore di documenti -GenericName[ja]=文書ビューア -GenericName[kk]=Құжатты қарау GenericName[km]=កម្មវិធី​មើល​ឯកសារ -GenericName[ko]=문서 뷰어 -GenericName[lv]=Dokumentu skatītājs -GenericName[nb]=Dokumentviser -GenericName[nds]=Dokmentkieker -GenericName[ne]=कागजात दर्शक -GenericName[nl]=Documentenviewer -GenericName[nn]=Dokumentvisar GenericName[oc]=Visualizaire de documents -GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ -GenericName[pl]=Przeglądarka dokumentów GenericName[pt]=Visualizador de Documentos -GenericName[pt_BR]=Visualizador de documentos -GenericName[ru]=Просмотр документов -GenericName[sl]=Pregledovalnik dokumentov +GenericName[pt_BR]=Visualizador de Documentos +GenericName[ro]=Vizualizator documente GenericName[sv]=Dokumentvisare -GenericName[th]=เครื่องมือแสดงเอกสาร GenericName[tr]=Belge Gösterici GenericName[uk]=Переглядач документів GenericName[x-test]=xxDocument Viewerxx -GenericName[zh_CN]=文档查看器 -GenericName[zh_TW]=文件檢視器 Exec=okular %U %i -caption "%c" Icon=okular Type=Application diff --git a/okularMobi.desktop b/okularMobi.desktop index 3d772eff6..ea7ef5a71 100644 --- a/okularMobi.desktop +++ b/okularMobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Icon=okular Name=Okular +Name[hi]=ऑकुलर Name[x-test]=xxOkularxx X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart From 4361d56b2b979977f3afec151f13b456693bf778 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 10 Nov 2008 23:53:35 +0000 Subject: [PATCH 09/48] Thumbnail generator svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882597 --- CMakeLists.txt | 12 ++++++++++-- TODO | 2 ++ converter.cpp | 8 ++++++-- mobidocument.cpp | 2 +- mobipocket.cpp | 34 +++++++++++++++++++++++++++------- mobipocket.h | 5 +++-- mobithumbnail.cpp | 37 +++++++++++++++++++++++++++++++++++++ mobithumbnail.desktop | 8 ++++++++ mobithumbnail.h | 23 +++++++++++++++++++++++ 9 files changed, 117 insertions(+), 14 deletions(-) create mode 100644 mobithumbnail.cpp create mode 100644 mobithumbnail.desktop create mode 100644 mobithumbnail.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e7a290f7..16e57b959 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,15 +23,23 @@ set(okularGenerator_mobi_PART_SRCS generator_mobi.cpp ) +set(mobithumbnail_SRCS + mobipocket.cpp + decompressor.cpp + mobithumbnail.cpp +) + kde4_add_plugin(okularGenerator_mobi ${okularGenerator_mobi_PART_SRCS}) +kde4_add_plugin(mobithumbnail ${mobithumbnail_SRCS}) target_link_libraries(okularGenerator_mobi okularcore ${mobi_LIBRARIES} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) +target_link_libraries(mobithumbnail ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY} ) -install(TARGETS okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) +install(TARGETS mobithumbnail okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) ########### install files ############### -install( FILES libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES mobithumbnail.desktop libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install( FILES okularApplication_mobi.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install( diff --git a/TODO b/TODO index 77eb436a4..15a6fcdb2 100644 --- a/TODO +++ b/TODO @@ -2,3 +2,5 @@ - tests for Mobipocket classes - anchors (a filepos=) - decryption for DRMed files (may be impossible and/or illegal) +- strigi analyzer +- thumbnail generator does not for some files (DRMed i think) diff --git a/converter.cpp b/converter.cpp index 39a9a2124..c95cff13a 100644 --- a/converter.cpp +++ b/converter.cpp @@ -50,8 +50,12 @@ QTextDocument* Converter::convert( const QString &fileName ) { MobiDocument* newDocument=new MobiDocument(fileName); if (!newDocument->mobi()->isValid()) { - if (newDocument->mobi()->hasDRM()) emit error(i18n("This book is protected by DRM and can be displayed only on designated device"), -1); - else emit error(i18n("Error while opening the Mobipocket document."), -1); + emit error(i18n("Error while opening the Mobipocket document."), -1); + delete newDocument; + return NULL; + } + if (newDocument->mobi()->hasDRM()) { + emit error(i18n("This book is protected by DRM and can be displayed only on designated device"), -1); delete newDocument; return NULL; } diff --git a/mobidocument.cpp b/mobidocument.cpp index 7affc2626..adce53e72 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -40,7 +40,7 @@ QVariant MobiDocument::loadResource(int type, const QUrl &name) if (!ok || recnum>=doc->imageCount()) return QVariant(); QVariant resource; - resource.setValue(doc->getImage(recnum)); + resource.setValue(doc->getImage(recnum-1)); addResource(type, name, resource); return resource; diff --git a/mobipocket.cpp b/mobipocket.cpp index 0d8e009c5..148b7375b 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -86,23 +86,30 @@ int PDB::recordCount() const //////////////////////////////////////////// struct DocumentPrivate { - DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), drm(false) {} + DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), + drm(false), thumbnailIndex(0) {} PDB pdb; Decompressor* dec; quint16 ntextrecords; bool valid; + + // number of first record holding image. Usually it is directly after end of text, but not always quint16 firstImageRecord; QMap metadata; bool isUtf; bool drm; + // index of thumbnail in image list. May be specified in EXTH. + // If not then just use first image and hope for the best + int thumbnailIndex; + void init(); void findFirstImage(); void parseEXTH(const QByteArray& data); void parseHtmlHead(const QString& data); QString readEXTHRecord(const QByteArray& data, quint32& offset); QString decodeString(const QByteArray& data) const; - + QImage getImageFromRecord(int recnum); }; QString DocumentPrivate::decodeString(const QByteArray& data) const @@ -139,7 +146,7 @@ void DocumentPrivate::init() QByteArray mhead=pdb.getRecord(0); dec = Decompressor::create(mhead[1], pdb); if ((int)mhead[12]!=0 || (int)mhead[13]!=0) drm=true; - if (!dec || drm) { + if (!dec) { valid=false; return; } @@ -151,7 +158,7 @@ void DocumentPrivate::init() if (mhead.size()>176) parseEXTH(mhead); // try getting metadata from HTML if nothing or only title was recovered from MOBI and EXTH records - if (metadata.size()<2) parseHtmlHead(decodeString(dec->decompress(pdb.getRecord(1)))); + if (metadata.size()<2 && !drm) parseHtmlHead(decodeString(dec->decompress(pdb.getRecord(1)))); } void DocumentPrivate::findFirstImage() { @@ -177,6 +184,14 @@ QString DocumentPrivate::readEXTHRecord(const QByteArray& data, quint32& offset) return ret; } +QImage DocumentPrivate::getImageFromRecord(int i) +{ + QByteArray rec=pdb.getRecord(i); + QByteArray rec2=pdb.getRecord(i-2); + return QImage::fromData(rec); +} + + void DocumentPrivate::parseEXTH(const QByteArray& data) { // try to get name @@ -201,6 +216,7 @@ void DocumentPrivate::parseEXTH(const QByteArray& data) case 103: metadata[Document::Description]=readEXTHRecord(data,offset); break; case 105: metadata[Document::Subject]=readEXTHRecord(data,offset); break; case 109: metadata[Document::Copyright]=readEXTHRecord(data,offset); break; + case 202: thumbnailIndex = readBELong(data,offset); offset+=4; break; default: readEXTHRecord(data,offset); } } @@ -240,9 +256,7 @@ bool Document::isValid() const QImage Document::getImage(int i) const { if (!d->firstImageRecord) d->findFirstImage(); - QByteArray rec=d->pdb.getRecord(d->firstImageRecord+i-1); - //FIXME: check if i is in range - return QImage::fromData(rec); + return d->getImageFromRecord(d->firstImageRecord+i); } QMap Document::metadata() const @@ -255,4 +269,10 @@ bool Document::hasDRM() const return d->drm; } +QImage Document::thumbnail() const +{ + if (!d->firstImageRecord) d->findFirstImage(); + return d->getImageFromRecord(d->thumbnailIndex+d->firstImageRecord); +} + } diff --git a/mobipocket.h b/mobipocket.h index ea2a408a3..2aa4b73e9 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -42,9 +42,10 @@ public: QString text() const; int imageCount() const; QImage getImage(int i) const; + QImage thumbnail() const; bool isValid() const; - - // if true then isValid() will return false + + // if true then it is impossible to get text of book. Images should still be readable bool hasDRM() const; private: DocumentPrivate* const d; diff --git a/mobithumbnail.cpp b/mobithumbnail.cpp new file mode 100644 index 000000000..ed1e5fb68 --- /dev/null +++ b/mobithumbnail.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#include "mobithumbnail.h" +#include "mobipocket.h" + +#include + +extern "C" +{ + KDE_EXPORT ThumbCreator *new_creator() + { + return new MobiThumbnail; + } +} + +bool MobiThumbnail::create(const QString &path, int width, int height, QImage &img) +{ + QFile f(path); + f.open(QIODevice::ReadOnly); + Mobipocket::Document doc(&f); + if (!doc.isValid()) return false; + img=doc.thumbnail(); + return !img.isNull(); +} + +ThumbCreator::Flags MobiThumbnail::flags() const +{ + return static_cast(None); +} + diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop new file mode 100644 index 000000000..757d03ba1 --- /dev/null +++ b/mobithumbnail.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Service +Name=Mobipocket thumbnailer +X-KDE-ServiceTypes=ThumbCreator +MimeType=application/x-mobipocket; +X-KDE-Library=mobithumbnail +CacheThumbnail=true + diff --git a/mobithumbnail.h b/mobithumbnail.h new file mode 100644 index 000000000..78c2d7196 --- /dev/null +++ b/mobithumbnail.h @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#ifndef MOBITHUMBNAIL_H +#define MOBITHUMBNAIL_H + +#include + +class MobiThumbnail : public ThumbCreator +{ +public: + MobiThumbnail() {} + virtual bool create(const QString &path, int, int, QImage &img); + virtual Flags flags() const; +}; + +#endif From 34f6c62c8a04d1c2ac92793fdc14c924f9c9ea67 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Tue, 11 Nov 2008 00:17:08 +0000 Subject: [PATCH 10/48] Fixed thumbnail generation for some files svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882600 --- TODO | 1 - mobipocket.cpp | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 15a6fcdb2..d5ce24484 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,3 @@ - anchors (a filepos=) - decryption for DRMed files (may be impossible and/or illegal) - strigi analyzer -- thumbnail generator does not for some files (DRMed i think) diff --git a/mobipocket.cpp b/mobipocket.cpp index 148b7375b..1fb046226 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -272,7 +272,13 @@ bool Document::hasDRM() const QImage Document::thumbnail() const { if (!d->firstImageRecord) d->findFirstImage(); - return d->getImageFromRecord(d->thumbnailIndex+d->firstImageRecord); + QImage img=d->getImageFromRecord(d->thumbnailIndex+d->firstImageRecord); + // does not work, try first image + if (img.isNull() && d->thumbnailIndex) { + d->thumbnailIndex=0; + img=d->getImageFromRecord(d->firstImageRecord); + } + return img; } } From 254d2098cdf4c8f3b477dd55a913515bb497e476 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 11 Nov 2008 13:11:54 +0000 Subject: [PATCH 11/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=882845 --- libokularGenerator_mobi.desktop | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index c9d97a6a5..55d00f7a5 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,7 +1,9 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular +Comment[uk]=Сервер Mobipocket для Okular X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket; X-KDE-Library=okularGenerator_mobi From d8ae4fd45819d8f7b1c564eaa8b7588c215e4551 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Tue, 11 Nov 2008 22:08:26 +0000 Subject: [PATCH 12/48] Add support for links in document. Internal links are not completely reliable yet. svn path=/trunk/playground/graphics/okular/mobipocket/; revision=883025 --- converter.cpp | 38 +++++++++++++++++++++++++++++++++++++- mobidocument.cpp | 45 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 73 insertions(+), 10 deletions(-) diff --git a/converter.cpp b/converter.cpp index c95cff13a..9bd8a90ba 100644 --- a/converter.cpp +++ b/converter.cpp @@ -11,8 +11,9 @@ #include #include +#include #include -#include +#include #include #include #include @@ -67,5 +68,40 @@ QTextDocument* Converter::convert( const QString &fileName ) frameFormat.setMargin( 20 ); QTextFrame *rootFrame = newDocument->rootFrame(); rootFrame->setFrameFormat( frameFormat ); + QMap > links; + QMap targets; + + // go over whole document and add all tags to links or targets map + for (QTextBlock it = newDocument->begin(); it != newDocument->end(); it = it.next()) + for (QTextBlock::iterator fit=it.begin(); !fit.atEnd(); ++fit) { + QTextFragment frag=fit.fragment(); + QTextCharFormat format=frag.charFormat(); + if (!format.isAnchor()) continue; + //link + if (!format.anchorHref().isEmpty()) links[format.anchorHref()]= + QPair(frag.position(), frag.position()+frag.length()); + if (!format.anchorNames().isEmpty()) { + // link targets + Q_FOREACH(QString name, format.anchorNames()) + targets["#"+name]=it; + } + } + + // create link actions + QMapIterator > it(links); + while (it.hasNext()) { + it.next(); + QUrl u(it.key()); + // external or internal link + if (!u.isRelative()) emit addAction(new Okular::BrowseAction(it.key()), it.value().first, it.value().second); + else { + // is there valid target? + if (!targets.contains( it.key() ) || !targets[it.key()].isValid()) continue; + emit addAction(new Okular::GotoAction(QString(), calculateViewport( newDocument, targets[it.key()] )), + it.value().first, it.value().second); + } + + } + return newDocument; } diff --git a/mobidocument.cpp b/mobidocument.cpp index adce53e72..641b6367a 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -8,8 +8,8 @@ ***************************************************************************/ #include "mobidocument.h" #include "mobipocket.h" -#include -#include +#include +#include #include using namespace Mobi; @@ -30,13 +30,9 @@ MobiDocument::~MobiDocument() QVariant MobiDocument::loadResource(int type, const QUrl &name) { - - kDebug() << "Requested resource: " << type << " URL " << name; - if (type!=QTextDocument::ImageResource || name.scheme()!=QString("pdbrec")) return QVariant(); bool ok; quint16 recnum=name.path().mid(1).toUShort(&ok); - kDebug() << "Path" << name.path().mid(1) << " Img " << recnum << " all imgs " << doc->imageCount(); if (!ok || recnum>=doc->imageCount()) return QVariant(); QVariant resource; @@ -46,15 +42,46 @@ QVariant MobiDocument::loadResource(int type, const QUrl &name) return resource; } +// starting from 'pos', find position in the string that is not inside a tag +int outsideTag(const QString& data, int pos) +{ + for (int i=pos-1;i>=0;i--) { + if (data[i]=='>') return pos; + if (data[i]=='<') return i; + } + return pos; +} QString MobiDocument::fixMobiMarkup(const QString& data) { - QRegExp imgs("<[iI][mM][gG].*recindex=\"([0-9]*)\".*>"); + static QRegExp imgs("", Qt::CaseInsensitive); imgs.setMinimal(true); QString ret=data; ret.replace(imgs,""); - ret.replace("","

"); - //FIXME: anchors + //ret.replace("","

"); + QMap anchorPositions; + static QRegExp anchors(" it(anchorPositions); + while (it.hasNext()) { + it.next(); + int fixedpos=outsideTag(ret, it.key()+offset); + ret.insert(fixedpos,QString("
")); + offset+=12+it.value().size(); + } + + // replace links referencing filepos with normal internal links + ret.replace(anchors," Date: Wed, 12 Nov 2008 13:49:20 +0000 Subject: [PATCH 13/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=883263 --- libokularGenerator_mobi.desktop | 10 ++++++++++ mobithumbnail.desktop | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 55d00f7a5..913f3d611 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,8 +1,18 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[el]=Έγγραφο Mobipocket +Name[gl]=Documento Mobipocket +Name[pt]=Documento Mobipocket +Name[pt_BR]=Documento Mobipocket +Name[sv]=Mobipocket-dokument Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular +Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular +Comment[gl]=Infrastrutura de Mobipocket para Okular +Comment[pt]=Infra-estrutura do Mobipocket para o Okular +Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular +Comment[sv]=Mobipocket-gränssnitt för Okular Comment[uk]=Сервер Mobipocket для Okular X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket; diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 757d03ba1..86b88c8ee 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -1,6 +1,11 @@ [Desktop Entry] Type=Service Name=Mobipocket thumbnailer +Name[el]=Εικόνες επισκόπησης Mobipocket +Name[pt]=Miniaturas do Mobipocket +Name[pt_BR]=Miniaturas do Mobipocket +Name[sv]=Skapa Mobipocket-miniatyrbilder +Name[uk]=Інструмент створення мініатюр Mobipocket X-KDE-ServiceTypes=ThumbCreator MimeType=application/x-mobipocket; X-KDE-Library=mobithumbnail From 3b0f1744028b30c0409500ac4a8f4eb82648db5f Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Thu, 13 Nov 2008 19:33:31 +0000 Subject: [PATCH 14/48] Strigi analyzer form mobipocket format. svn path=/trunk/playground/graphics/okular/mobipocket/; revision=883893 --- CMakeLists.txt | 17 +++++++ TODO | 2 - converter.cpp | 2 +- mobidocument.cpp | 4 +- mobidocument.h | 3 +- mobiendanalyzer.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++ mobiendanalyzer.h | 47 +++++++++++++++++++ mobipocket.cpp | 41 ++++++++++------- mobipocket.h | 20 ++++++-- mobithumbnail.cpp | 4 +- qfilestream.h | 29 ++++++++++++ 11 files changed, 249 insertions(+), 28 deletions(-) create mode 100644 mobiendanalyzer.cpp create mode 100644 mobiendanalyzer.h create mode 100644 qfilestream.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 16e57b959..0225e2ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,10 @@ project(okular-mobi-generator) ENABLE_TESTING() find_package(KDE4 REQUIRED) +find_package(Strigi REQUIRED) include_directories(${KDE4_INCLUDES} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} + ${STRIGI_INCLUDE_DIR} ) ########### next target ############### @@ -29,18 +31,33 @@ set(mobithumbnail_SRCS mobithumbnail.cpp ) +set(mobianalyzer_SRCS + mobipocket.cpp + decompressor.cpp + mobiendanalyzer.cpp +) + kde4_add_plugin(okularGenerator_mobi ${okularGenerator_mobi_PART_SRCS}) kde4_add_plugin(mobithumbnail ${mobithumbnail_SRCS}) +kde4_add_library(mobi MODULE ${mobianalyzer_SRCS}) +# FIXME: remove QtGui dependency on analyzer + +target_link_libraries(mobi ${STRIGI_STREAMS_LIBRARY} ${STRIGI_STREAMANALYZER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) target_link_libraries(okularGenerator_mobi okularcore ${mobi_LIBRARIES} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) target_link_libraries(mobithumbnail ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY} ) install(TARGETS mobithumbnail okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) +# install the module in the right directory so it is picked up +set_target_properties(mobi PROPERTIES PREFIX ${STRIGI_LINE_ANALYZER_PREFIX}) + + ########### install files ############### install( FILES mobithumbnail.desktop libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install( FILES okularApplication_mobi.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install(TARGETS mobi LIBRARY DESTINATION ${LIB_INSTALL_DIR}/strigi) install( FILES x-mobipocket.xml diff --git a/TODO b/TODO index d5ce24484..db0e6800f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ - better error handling - tests for Mobipocket classes -- anchors (a filepos=) - decryption for DRMed files (may be impossible and/or illegal) -- strigi analyzer diff --git a/converter.cpp b/converter.cpp index 9bd8a90ba..611b8951a 100644 --- a/converter.cpp +++ b/converter.cpp @@ -82,7 +82,7 @@ QTextDocument* Converter::convert( const QString &fileName ) QPair(frag.position(), frag.position()+frag.length()); if (!format.anchorNames().isEmpty()) { // link targets - Q_FOREACH(QString name, format.anchorNames()) + Q_FOREACH(const QString& name, format.anchorNames()) targets["#"+name]=it; } } diff --git a/mobidocument.cpp b/mobidocument.cpp index 641b6367a..d4e9071f2 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -8,6 +8,7 @@ ***************************************************************************/ #include "mobidocument.h" #include "mobipocket.h" +#include "qfilestream.h" #include #include #include @@ -16,8 +17,7 @@ using namespace Mobi; MobiDocument::MobiDocument(const QString &fileName) : QTextDocument() { - file = new QFile(fileName); - file->open(QIODevice::ReadOnly); + file = new Mobipocket::QFileStream(fileName); doc = new Mobipocket::Document(file); if (doc->isValid()) setHtml(fixMobiMarkup(doc->text())); } diff --git a/mobidocument.h b/mobidocument.h index 47b8328a0..1d1b9bf55 100644 --- a/mobidocument.h +++ b/mobidocument.h @@ -16,6 +16,7 @@ class QFile; namespace Mobipocket { class Document; +class QFileStream; } namespace Mobi { @@ -34,7 +35,7 @@ namespace Mobi { private: QString fixMobiMarkup(const QString& data); Mobipocket::Document *doc; - QFile* file; + Mobipocket::QFileStream* file; }; } diff --git a/mobiendanalyzer.cpp b/mobiendanalyzer.cpp new file mode 100644 index 000000000..2d9eda299 --- /dev/null +++ b/mobiendanalyzer.cpp @@ -0,0 +1,108 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + + +#include "mobiendanalyzer.h" + +#define STRIGI_IMPORT_API +#include +#include +#include +#include +#include +#include + +#include "mobipocket.h" + +using namespace Strigi; + +class StrigiStream : public Mobipocket::Stream +{ +public: + StrigiStream(InputStream* str) : d(str) {} + int read(char* buf, int len) { + const char* b2; + int l=d->read(b2, len,len); + memcpy(buf,b2,len); + return l; + } + void seek(int pos) { d->reset(pos); } +private: + InputStream *d; +}; + +void +MobiEndAnalyzerFactory::registerFields(FieldRegister& reg) { + subjectField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#subject"); + titleField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#title"); + authorField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#author"); + descriptionField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#description"); + copyrightField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#copyright"); + encryptedField = reg.registerField( + "http://freedesktop.org/standards/xesam/1.0/core#isContentEncrypted"); +// typeField = reg.typeField; + //FIXME: check other fields - for example encryption + + /* add the fields to the internal list of fields */ + addField(subjectField); + addField(titleField); + addField(authorField); + addField(descriptionField); + addField(copyrightField); + addField(encryptedField); +// addField(typeField); +} + +MobiEndAnalyzer::MobiEndAnalyzer(const MobiEndAnalyzerFactory* f) :factory(f) { +} +bool +MobiEndAnalyzer::checkHeader(const char* header, int32_t headersize) const { + static const char magic1[] = "TEXtREAd"; + static const char magic2[] = "BOOKMOBI"; + return headersize >= 67 && (!memcmp(header+60, magic1, 8) || !memcmp(header+60, magic2, 8)); +} + +signed char +MobiEndAnalyzer::analyze(AnalysisResult& as, InputStream* in) { + StrigiStream str(in); + Mobipocket::Document doc(&str); + if (!doc.isValid()) return -1; +// as.addValue(factory->typeField, "http://freedesktop.org/standards/xesam/1.0/core#Document"); + as.addValue(factory->encryptedField, doc.hasDRM()); + QMapIterator it(doc.metadata()); + while (it.hasNext()) { + it.next(); + switch (it.key()) { + case Mobipocket::Document::Title: as.addValue(factory->titleField, it.value().toUtf8().data() ); break; + case Mobipocket::Document::Author: as.addValue(factory->authorField, it.value().toUtf8().data() ); break; + case Mobipocket::Document::Description: as.addValue(factory->descriptionField, it.value().toUtf8().data() ); break; + case Mobipocket::Document::Subject: as.addValue(factory->subjectField, it.value().toUtf8().data() ); break; + case Mobipocket::Document::Copyright: as.addValue(factory->copyrightField, it.value().toUtf8().data() ); break; + } + } + return 0; +} + +class Factory : public AnalyzerFactoryFactory +{ +public: + std::list + streamEndAnalyzerFactories() const { + std::list af; + af.push_back(new MobiEndAnalyzerFactory()); + return af; + } +}; + +STRIGI_ANALYZER_FACTORY(Factory) diff --git a/mobiendanalyzer.h b/mobiendanalyzer.h new file mode 100644 index 000000000..72de1df66 --- /dev/null +++ b/mobiendanalyzer.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#ifndef MOBIENDANALYZER +#define MOBIENDANALYZER + +#include +#include + +class MobiEndAnalyzerFactory; +class MobiEndAnalyzer : public Strigi::StreamEndAnalyzer { +private: + const MobiEndAnalyzerFactory* factory; + bool checkHeader(const char* header, int32_t headersize) const; + signed char analyze(Strigi::AnalysisResult& idx, Strigi::InputStream* in); + const char* name() const { return "MobiEndAnalyzer"; } +public: + MobiEndAnalyzer(const MobiEndAnalyzerFactory* f); +}; + +class MobiEndAnalyzerFactory : public Strigi::StreamEndAnalyzerFactory { +friend class MobiEndAnalyzer; +private: + const Strigi::RegisteredField* titleField; + const Strigi::RegisteredField* authorField; + const Strigi::RegisteredField* copyrightField; + const Strigi::RegisteredField* subjectField; + const Strigi::RegisteredField* descriptionField; + const Strigi::RegisteredField* encryptedField; +// const Strigi::RegisteredField* typeField; + + const char* name() const { + return "MobiEndAnalyzer"; + } + Strigi::StreamEndAnalyzer* newInstance() const { + return new MobiEndAnalyzer(this); + } + void registerFields(Strigi::FieldRegister&); +}; + +#endif diff --git a/mobipocket.cpp b/mobipocket.cpp index 1fb046226..6a72211e5 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -18,11 +18,29 @@ namespace Mobipocket { +QByteArray Stream::read(int len) +{ + QByteArray ret; + ret.resize(len); + len=read(ret.data(),len); + if (len<0) len=0; + ret.resize(len); + return ret; +} + +QByteArray Stream::readAll() +{ + QByteArray ret, bit; + while (!(bit=read(4096)).isEmpty()) ret+=bit; + return ret; +} + + + struct PDBPrivate { QList recordOffsets; - QIODevice* device; + Stream* device; QString fileType; - QString name; quint16 nrecords; bool valid; @@ -34,8 +52,6 @@ void PDBPrivate::init() valid=true; quint16 word; quint32 dword; - device->seek(0); - name=QString::fromLatin1(device->read(32)); device->seek(0x3c); fileType=QString::fromLatin1(device->read(8)); @@ -50,7 +66,7 @@ void PDBPrivate::init() } } -PDB::PDB(QIODevice* dev) : d(new PDBPrivate) +PDB::PDB(Stream* dev) : d(new PDBPrivate) { d->device=dev; d->init(); @@ -61,16 +77,9 @@ QByteArray PDB::getRecord(int i) const if (i>=d->nrecords) return QByteArray(); quint32 offset=d->recordOffsets[i]; bool last=(i==(d->nrecords-1)); - quint32 size=0; - if (last) size=d->device->size()-offset; - else size=d->recordOffsets[i+1]-offset; d->device->seek(offset); - return d->device->read(size); -} - -QString PDB::name() const -{ - return d->name; + if (last) return d->device->readAll(); + return d->device->read(d->recordOffsets[i+1]-offset); } bool PDB::isValid() const @@ -86,7 +95,7 @@ int PDB::recordCount() const //////////////////////////////////////////// struct DocumentPrivate { - DocumentPrivate(QIODevice* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), + DocumentPrivate(Stream* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), drm(false), thumbnailIndex(0) {} PDB pdb; Decompressor* dec; @@ -224,7 +233,7 @@ void DocumentPrivate::parseEXTH(const QByteArray& data) } -Document::Document(QIODevice* dev) : d(new DocumentPrivate(dev)) +Document::Document(Stream* dev) : d(new DocumentPrivate(dev)) { d->init(); } diff --git a/mobipocket.h b/mobipocket.h index 2aa4b73e9..f8521bfb4 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -19,15 +19,27 @@ class QIODevice; namespace Mobipocket { -struct PDBPrivate; +/** +Minimalistic stream abstraction. It is supposed to allow mobipocket document classes to be +used with both QIODevice (for Okular generator) and InputStream for Strigi analyzer. +*/ +class Stream { +public: + virtual int read(char* buf, int size)=0; + virtual void seek(int pos)=0; + QByteArray readAll(); + QByteArray read(int len); + virtual ~Stream() {} +}; + +struct PDBPrivate; class PDB { public: - PDB(QIODevice* dev); + PDB(Stream* s); QString fileType() const; int recordCount() const; QByteArray getRecord(int i) const; - QString name() const; bool isValid() const; private: PDBPrivate* const d; @@ -37,7 +49,7 @@ struct DocumentPrivate; class Document { public: enum MetaKey { Title, Author, Copyright, Description, Subject }; - Document(QIODevice* dev); + Document(Stream* s); QMap metadata() const; QString text() const; int imageCount() const; diff --git a/mobithumbnail.cpp b/mobithumbnail.cpp index ed1e5fb68..aea8a74a7 100644 --- a/mobithumbnail.cpp +++ b/mobithumbnail.cpp @@ -9,6 +9,7 @@ #include "mobithumbnail.h" #include "mobipocket.h" +#include "qfilestream.h" #include @@ -22,8 +23,7 @@ extern "C" bool MobiThumbnail::create(const QString &path, int width, int height, QImage &img) { - QFile f(path); - f.open(QIODevice::ReadOnly); + Mobipocket::QFileStream f(path); Mobipocket::Document doc(&f); if (!doc.isValid()) return false; img=doc.thumbnail(); diff --git a/qfilestream.h b/qfilestream.h new file mode 100644 index 000000000..ea0b9c30a --- /dev/null +++ b/qfilestream.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2008 by Jakub Stachowski * + * * + * 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. * + ***************************************************************************/ + +#ifndef QFILESTREAM_H +#define QFILESTREAM_H + +#include +#include "mobipocket.h" + +namespace Mobipocket { + +class QFileStream : public Stream +{ +public: + QFileStream(const QString& name) : d(name) { d.open(QIODevice::ReadOnly); } + int read(char* buf, int size) { return d.read(buf,size); } + void seek(int pos) { d.seek(pos); } +private: + QFile d; +}; + +} +#endif From c63fd0fb882e98368570c337c882afd521cb0899 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 16 Nov 2008 18:29:19 +0000 Subject: [PATCH 15/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=885189 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 913f3d611..717531ae1 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -2,6 +2,7 @@ Type=Service Name=Mobipocket document Name[el]=Έγγραφο Mobipocket +Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket @@ -9,6 +10,7 @@ Name[sv]=Mobipocket-dokument Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular +Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular Comment[pt]=Infra-estrutura do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 86b88c8ee..808babe05 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -2,6 +2,7 @@ Type=Service Name=Mobipocket thumbnailer Name[el]=Εικόνες επισκόπησης Mobipocket +Name[fr]=Afficheur d'aperçus Mobipocket Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder From c1d0341580d411eba4b92f28049a2ce2c357c39b Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 17 Nov 2008 13:28:35 +0000 Subject: [PATCH 16/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=885575 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 717531ae1..359ae678e 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -8,6 +8,7 @@ Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument Name[uk]=Документ Mobipocket +Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[fr]=Moteur Mobipocket pour Okular @@ -16,6 +17,7 @@ Comment[pt]=Infra-estrutura do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular Comment[uk]=Сервер Mobipocket для Okular +Comment[x-test]=xxMobipocket backend for Okularxx X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket; X-KDE-Library=okularGenerator_mobi diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 808babe05..84e3fb0af 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -7,6 +7,7 @@ Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder Name[uk]=Інструмент створення мініатюр Mobipocket +Name[x-test]=xxMobipocket thumbnailerxx X-KDE-ServiceTypes=ThumbCreator MimeType=application/x-mobipocket; X-KDE-Library=mobithumbnail From a08cb82c0d62adadc7caa8d550ee7c37a818d982 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 25 Nov 2008 13:16:17 +0000 Subject: [PATCH 17/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=888904 --- mobithumbnail.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 84e3fb0af..423b1b822 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -3,6 +3,7 @@ Type=Service Name=Mobipocket thumbnailer Name[el]=Εικόνες επισκόπησης Mobipocket Name[fr]=Afficheur d'aperçus Mobipocket +Name[gl]=Miniaturas para Mobipocket Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder From a0dcebe8e58e5f1e90e8b97c73f0223538464a84 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 27 Nov 2008 12:34:03 +0000 Subject: [PATCH 18/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=889711 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 359ae678e..c21f63772 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -4,6 +4,7 @@ Name=Mobipocket document Name[el]=Έγγραφο Mobipocket Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket +Name[km]=ឯកសារ Mobipocket Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument @@ -13,6 +14,7 @@ Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular +Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular Comment[pt]=Infra-estrutura do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 423b1b822..91ece1962 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -4,6 +4,7 @@ Name=Mobipocket thumbnailer Name[el]=Εικόνες επισκόπησης Mobipocket Name[fr]=Afficheur d'aperçus Mobipocket Name[gl]=Miniaturas para Mobipocket +Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder From 0fc3cd02ed74b207bbb2a6d5c07f392308a89a2b Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 4 Dec 2008 14:21:47 +0000 Subject: [PATCH 19/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=892535 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + okularApplication_mobi.desktop | 1 + 3 files changed, 4 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index c21f63772..443dbf9dd 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -5,6 +5,7 @@ Name[el]=Έγγραφο Mobipocket Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket Name[km]=ឯកសារ Mobipocket +Name[nds]=Mobipocket-Dokment Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument @@ -15,6 +16,7 @@ Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular +Comment[nds]=Mobipocket-Hülppropgramm för Okular Comment[pt]=Infra-estrutura do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 91ece1962..e23998ede 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -5,6 +5,7 @@ Name[el]=Εικόνες επισκόπησης Mobipocket Name[fr]=Afficheur d'aperçus Mobipocket Name[gl]=Miniaturas para Mobipocket Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket +Name[nds]=Mobipocket-Vöransichten Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 80af39885..db459ca67 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -13,6 +13,7 @@ GenericName[ga]=Amharcán Cáipéisí GenericName[gl]=Visor de documentos GenericName[hi]=दस्तावेज़ प्रदर्शक GenericName[km]=កម្មវិធី​មើល​ឯកសារ +GenericName[nds]=Dokmentkieker GenericName[oc]=Visualizaire de documents GenericName[pt]=Visualizador de Documentos GenericName[pt_BR]=Visualizador de Documentos From 0055715c78e1e0bf7bd093f111fa811cbb5d8f9c Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Thu, 4 Dec 2008 20:47:25 +0000 Subject: [PATCH 20/48] Add text to fulltext index too svn path=/trunk/playground/graphics/okular/mobipocket/; revision=892658 --- mobiendanalyzer.cpp | 2 ++ mobipocket.cpp | 3 ++- mobipocket.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mobiendanalyzer.cpp b/mobiendanalyzer.cpp index 2d9eda299..caa4fa911 100644 --- a/mobiendanalyzer.cpp +++ b/mobiendanalyzer.cpp @@ -91,6 +91,8 @@ MobiEndAnalyzer::analyze(AnalysisResult& as, InputStream* in) { case Mobipocket::Document::Copyright: as.addValue(factory->copyrightField, it.value().toUtf8().data() ); break; } } + QByteArray text=doc.text(20480).toUtf8(); + as.addText(text.data(), text.size()); return 0; } diff --git a/mobipocket.cpp b/mobipocket.cpp index 6a72211e5..87b5d8e72 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -238,7 +238,7 @@ Document::Document(Stream* dev) : d(new DocumentPrivate(dev)) d->init(); } -QString Document::text() const +QString Document::text(int size) const { QByteArray whole; for (int i=1;intextrecords+1;i++) { @@ -247,6 +247,7 @@ QString Document::text() const d->valid=false; return QString::null; } + if (size!=-1 && whole.size()>size) break; } return d->decodeString(whole); } diff --git a/mobipocket.h b/mobipocket.h index f8521bfb4..24d084af9 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -51,7 +51,7 @@ public: enum MetaKey { Title, Author, Copyright, Description, Subject }; Document(Stream* s); QMap metadata() const; - QString text() const; + QString text(int size=-1) const; int imageCount() const; QImage getImage(int i) const; QImage thumbnail() const; From e41b9ccf0bf0daa78581b90df1273634814f2c82 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sat, 6 Dec 2008 15:42:09 +0000 Subject: [PATCH 21/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=893425 --- libokularGenerator_mobi.desktop | 1 + okularApplication_mobi.desktop | 1 + 2 files changed, 2 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 443dbf9dd..0f2127c4e 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[de]=Mobipocket-Dokument Name[el]=Έγγραφο Mobipocket Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index db459ca67..79253cb9b 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -5,6 +5,7 @@ Name=Okular Name[hi]=ऑकुलर Name[x-test]=xxOkularxx GenericName=Document Viewer +GenericName[de]=Dokumentenbetrachter GenericName[el]=Προβολέας εγγράφου GenericName[es]=Visor de documentos GenericName[et]=Dokumendinäitaja From e6e06c393b961d8d13fccc26edf5f8916655b9d6 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 8 Dec 2008 13:48:57 +0000 Subject: [PATCH 22/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=894379 --- okularApplication_mobi.desktop | 2 ++ okularMobi.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 79253cb9b..991f789bd 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -3,6 +3,7 @@ MimeType=application/x-mobipocket; Terminal=false Name=Okular Name[hi]=ऑकुलर +Name[pa]=ਓਕੁਲਾਰ Name[x-test]=xxOkularxx GenericName=Document Viewer GenericName[de]=Dokumentenbetrachter @@ -16,6 +17,7 @@ GenericName[hi]=दस्तावेज़ प्रदर्शक GenericName[km]=កម្មវិធី​មើល​ឯកសារ GenericName[nds]=Dokmentkieker GenericName[oc]=Visualizaire de documents +GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ GenericName[pt]=Visualizador de Documentos GenericName[pt_BR]=Visualizador de Documentos GenericName[ro]=Vizualizator documente diff --git a/okularMobi.desktop b/okularMobi.desktop index ea7ef5a71..ea64d09dc 100644 --- a/okularMobi.desktop +++ b/okularMobi.desktop @@ -2,6 +2,7 @@ Icon=okular Name=Okular Name[hi]=ऑकुलर +Name[pa]=ਓਕੁਲਾਰ Name[x-test]=xxOkularxx X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart From 9d75b36f60f12bc44cb5331205c0b807669d7848 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Fri, 12 Dec 2008 21:44:35 +0000 Subject: [PATCH 23/48] Proper mime type svn path=/trunk/playground/graphics/okular/mobipocket/; revision=896219 --- CMakeLists.txt | 2 +- libokularGenerator_mobi.desktop | 2 +- okularApplication_mobi.desktop | 2 +- okularMobi.desktop | 2 +- x-mobipocket-ebook.xml | 12 ++++++++++++ x-mobipocket.xml | 8 -------- 6 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 x-mobipocket-ebook.xml delete mode 100644 x-mobipocket.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 0225e2ef0..4b5689304 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ install( FILES okularApplication_mobi.desktop DESTINATION ${XDG_APPS_INSTALL_D install(TARGETS mobi LIBRARY DESTINATION ${LIB_INSTALL_DIR}/strigi) install( - FILES x-mobipocket.xml + FILES x-mobipocket-ebook.xml DESTINATION ${XDG_MIME_INSTALL_DIR} ) update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR}) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 0f2127c4e..5d938d1f2 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -24,7 +24,7 @@ Comment[sv]=Mobipocket-gränssnitt för Okular Comment[uk]=Сервер Mobipocket для Okular Comment[x-test]=xxMobipocket backend for Okularxx X-KDE-ServiceTypes=okular/Generator -MimeType=application/x-mobipocket; +MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi X-KDE-Priority=1 X-KDE-okularAPIVersion=1 diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 991f789bd..aa17b8e0f 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -MimeType=application/x-mobipocket; +MimeType=application/x-mobipocket-ebook; Terminal=false Name=Okular Name[hi]=ऑकुलर diff --git a/okularMobi.desktop b/okularMobi.desktop index ea64d09dc..d0b6584ba 100644 --- a/okularMobi.desktop +++ b/okularMobi.desktop @@ -7,4 +7,4 @@ Name[x-test]=xxOkularxx X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart Type=Service -MimeType=application/x-mobipocket; +MimeType=application/x-mobipocket-ebook; diff --git a/x-mobipocket-ebook.xml b/x-mobipocket-ebook.xml new file mode 100644 index 000000000..8de52fc14 --- /dev/null +++ b/x-mobipocket-ebook.xml @@ -0,0 +1,12 @@ + + + + E-book in Mobipocket format + + + + + + + + diff --git a/x-mobipocket.xml b/x-mobipocket.xml deleted file mode 100644 index aa7316687..000000000 --- a/x-mobipocket.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - Mobipocket document - - - - From 6f914a765d6b65e2bd669310302e6e223f313475 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Thu, 18 Dec 2008 07:47:14 +0000 Subject: [PATCH 24/48] Fix forward declaration svn path=/trunk/playground/graphics/okular/mobipocket/; revision=898406 --- converter.h | 1 - 1 file changed, 1 deletion(-) diff --git a/converter.h b/converter.h index 1ee9d1c93..038fcc444 100644 --- a/converter.h +++ b/converter.h @@ -15,7 +15,6 @@ #include "mobidocument.h" #include "mobipocket.h" -class QTextCursor; namespace Mobi { class Converter : public Okular::TextDocumentConverter From 391f5d2dc95d656ae19dc75c8af3ac407a5bf0a0 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 22 Dec 2008 14:22:34 +0000 Subject: [PATCH 25/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=900295 --- okularApplication_mobi.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index aa17b8e0f..b16658021 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -16,6 +16,7 @@ GenericName[gl]=Visor de documentos GenericName[hi]=दस्तावेज़ प्रदर्शक GenericName[km]=កម្មវិធី​មើល​ឯកសារ GenericName[nds]=Dokmentkieker +GenericName[nl]=Documentenviewer GenericName[oc]=Visualizaire de documents GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ GenericName[pt]=Visualizador de Documentos From 7d9a51452abc0d969b5a51da9e088ae8e163e0d7 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 23 Dec 2008 13:02:31 +0000 Subject: [PATCH 26/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=900718 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 5d938d1f2..73e96741c 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -7,6 +7,7 @@ Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket Name[km]=ឯកសារ Mobipocket Name[nds]=Mobipocket-Dokment +Name[nl]=Mobipocket-document Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument @@ -18,6 +19,7 @@ Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular Comment[nds]=Mobipocket-Hülppropgramm för Okular +Comment[nl]=Mobipocket backend voor Okular Comment[pt]=Infra-estrutura do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index e23998ede..fbde722d9 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -6,6 +6,7 @@ Name[fr]=Afficheur d'aperçus Mobipocket Name[gl]=Miniaturas para Mobipocket Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket Name[nds]=Mobipocket-Vöransichten +Name[nl]=Mobipocket-miniatuurmaker Name[pt]=Miniaturas do Mobipocket Name[pt_BR]=Miniaturas do Mobipocket Name[sv]=Skapa Mobipocket-miniatyrbilder From c6a896d503ec9a9308bc81089d96684037a9c77b Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Wed, 31 Dec 2008 14:43:24 +0000 Subject: [PATCH 27/48] Fix mime in thumbnailer svn path=/trunk/playground/graphics/okular/mobipocket/; revision=903855 --- mobithumbnail.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index fbde722d9..9ca9a5c42 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -13,7 +13,7 @@ Name[sv]=Skapa Mobipocket-miniatyrbilder Name[uk]=Інструмент створення мініатюр Mobipocket Name[x-test]=xxMobipocket thumbnailerxx X-KDE-ServiceTypes=ThumbCreator -MimeType=application/x-mobipocket; +MimeType=application/x-mobipocket-ebook; X-KDE-Library=mobithumbnail CacheThumbnail=true From ea630c837cda8b2b4579e191457c760b98ad8036 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Wed, 31 Dec 2008 23:35:32 +0000 Subject: [PATCH 28/48] Do not try to extract text from DRM-ed files svn path=/trunk/playground/graphics/okular/mobipocket/; revision=903974 --- mobiendanalyzer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mobiendanalyzer.cpp b/mobiendanalyzer.cpp index caa4fa911..ed83f8359 100644 --- a/mobiendanalyzer.cpp +++ b/mobiendanalyzer.cpp @@ -91,8 +91,10 @@ MobiEndAnalyzer::analyze(AnalysisResult& as, InputStream* in) { case Mobipocket::Document::Copyright: as.addValue(factory->copyrightField, it.value().toUtf8().data() ); break; } } - QByteArray text=doc.text(20480).toUtf8(); - as.addText(text.data(), text.size()); + if (!doc.hasDRM()) { + QByteArray text=doc.text(20480).toUtf8(); + as.addText(text.data(), text.size()); + } return 0; } From 7a97b440fb675a413cb296b87b8db8ee3d5ea1f7 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Thu, 1 Jan 2009 15:05:20 +0000 Subject: [PATCH 29/48] Better error detection svn path=/trunk/playground/graphics/okular/mobipocket/; revision=904178 --- decompressor.cpp | 12 +++++++++--- mobiendanalyzer.cpp | 2 +- mobipocket.cpp | 30 ++++++++++++++++++------------ mobipocket.h | 2 +- mobithumbnail.cpp | 3 +++ qfilestream.h | 2 +- 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/decompressor.cpp b/decompressor.cpp index b63c796d3..04251c12a 100644 --- a/decompressor.cpp +++ b/decompressor.cpp @@ -163,12 +163,18 @@ HuffdicDecompressor::HuffdicDecompressor(const PDB& p) : Decompressor(p) QByteArray header=p.getRecord(0); quint32 huff_ofs=readBELong(header,0x70); quint32 huff_num=readBELong(header,0x74); + quint32 off1,off2; - for (unsigned int i=1;ireset(pos); } + bool seek(int pos) { d->reset(pos); return (pos==d->position()); } private: InputStream *d; }; diff --git a/mobipocket.cpp b/mobipocket.cpp index 87b5d8e72..7d7b5927d 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -52,10 +52,10 @@ void PDBPrivate::init() valid=true; quint16 word; quint32 dword; - device->seek(0x3c); + if (!device->seek(0x3c)) goto fail; fileType=QString::fromLatin1(device->read(8)); - device->seek(0x4c); + if (!device->seek(0x4c)) goto fail; device->read((char*)&word,2); nrecords=qFromBigEndian(word); @@ -64,6 +64,9 @@ void PDBPrivate::init() recordOffsets.append(qFromBigEndian(dword)); device->read((char*)&dword,4); } + return; + fail: + valid=false; } PDB::PDB(Stream* dev) : d(new PDBPrivate) @@ -77,7 +80,7 @@ QByteArray PDB::getRecord(int i) const if (i>=d->nrecords) return QByteArray(); quint32 offset=d->recordOffsets[i]; bool last=(i==(d->nrecords-1)); - d->device->seek(offset); + if (!d->device->seek(offset)) return QByteArray(); if (last) return d->device->readAll(); return d->device->read(d->recordOffsets[i+1]-offset); } @@ -150,24 +153,28 @@ void DocumentPrivate::parseHtmlHead(const QString& data) void DocumentPrivate::init() { + quint32 encoding; + valid=pdb.isValid(); if (!valid) return; QByteArray mhead=pdb.getRecord(0); + if (mhead.isNull()) goto fail; dec = Decompressor::create(mhead[1], pdb); if ((int)mhead[12]!=0 || (int)mhead[13]!=0) drm=true; - if (!dec) { - valid=false; - return; - } + if (!dec) goto fail; + ntextrecords=(unsigned char)mhead[8]; ntextrecords<<=8; ntextrecords+=(unsigned char)mhead[9]; - quint32 encoding=readBELong(mhead, 28); + encoding=readBELong(mhead, 28); if (encoding==65001) isUtf=true; if (mhead.size()>176) parseEXTH(mhead); // try getting metadata from HTML if nothing or only title was recovered from MOBI and EXTH records if (metadata.size()<2 && !drm) parseHtmlHead(decodeString(dec->decompress(pdb.getRecord(1)))); + return; +fail: + valid=false; } void DocumentPrivate::findFirstImage() { @@ -196,8 +203,7 @@ QString DocumentPrivate::readEXTHRecord(const QByteArray& data, quint32& offset) QImage DocumentPrivate::getImageFromRecord(int i) { QByteArray rec=pdb.getRecord(i); - QByteArray rec2=pdb.getRecord(i-2); - return QImage::fromData(rec); + return (rec.isNull()) ? QImage() : QImage::fromData(rec); } @@ -205,8 +211,8 @@ void DocumentPrivate::parseEXTH(const QByteArray& data) { // try to get name if (data.size()>=92) { - quint32 nameoffset=readBELong(data,84); - quint32 namelen=readBELong(data,88); + qint32 nameoffset=readBELong(data,84); + qint32 namelen=readBELong(data,88); if ( (nameoffset + namelen) < data.size() ) { metadata[Document::Title]=decodeString(data.mid(nameoffset, namelen)); } diff --git a/mobipocket.h b/mobipocket.h index 24d084af9..85c798a5a 100644 --- a/mobipocket.h +++ b/mobipocket.h @@ -26,7 +26,7 @@ used with both QIODevice (for Okular generator) and InputStream for Strigi analy class Stream { public: virtual int read(char* buf, int size)=0; - virtual void seek(int pos)=0; + virtual bool seek(int pos)=0; QByteArray readAll(); QByteArray read(int len); diff --git a/mobithumbnail.cpp b/mobithumbnail.cpp index aea8a74a7..a9e18db9b 100644 --- a/mobithumbnail.cpp +++ b/mobithumbnail.cpp @@ -23,6 +23,9 @@ extern "C" bool MobiThumbnail::create(const QString &path, int width, int height, QImage &img) { + Q_UNUSED(width); + Q_UNUSED(height); + Mobipocket::QFileStream f(path); Mobipocket::Document doc(&f); if (!doc.isValid()) return false; diff --git a/qfilestream.h b/qfilestream.h index ea0b9c30a..962a5b857 100644 --- a/qfilestream.h +++ b/qfilestream.h @@ -20,7 +20,7 @@ class QFileStream : public Stream public: QFileStream(const QString& name) : d(name) { d.open(QIODevice::ReadOnly); } int read(char* buf, int size) { return d.read(buf,size); } - void seek(int pos) { d.seek(pos); } + bool seek(int pos) { return d.seek(pos); } private: QFile d; }; From 8801de2f1a33f01ff32839a3039dcee48d44973b Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 5 Jan 2009 13:09:40 +0000 Subject: [PATCH 30/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=906050 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 73e96741c..abc373091 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -3,6 +3,7 @@ Type=Service Name=Mobipocket document Name[de]=Mobipocket-Dokument Name[el]=Έγγραφο Mobipocket +Name[es]=Documento Mobipocket Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket Name[km]=ឯកសារ Mobipocket @@ -15,6 +16,7 @@ Name[uk]=Документ Mobipocket Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular +Comment[es]=Motor Mobipocket para Okular Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 9ca9a5c42..8be2ef82c 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -2,6 +2,7 @@ Type=Service Name=Mobipocket thumbnailer Name[el]=Εικόνες επισκόπησης Mobipocket +Name[es]=Miniaturas para Mobipocket Name[fr]=Afficheur d'aperçus Mobipocket Name[gl]=Miniaturas para Mobipocket Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket From 579d43b5ac5f243a8d0418dfca839c6e10ad7401 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Thu, 8 Jan 2009 17:34:38 +0000 Subject: [PATCH 31/48] Deal with krazy warnings svn path=/trunk/playground/graphics/okular/mobipocket/; revision=907738 --- converter.cpp | 2 +- decompressor.cpp | 8 ++++---- generator_mobi.h | 4 ++-- mobiendanalyzer.cpp | 2 +- mobiendanalyzer.h | 2 +- mobipocket.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/converter.cpp b/converter.cpp index 611b8951a..7012d5c40 100644 --- a/converter.cpp +++ b/converter.cpp @@ -83,7 +83,7 @@ QTextDocument* Converter::convert( const QString &fileName ) if (!format.anchorNames().isEmpty()) { // link targets Q_FOREACH(const QString& name, format.anchorNames()) - targets["#"+name]=it; + targets['#'+name]=it; } } diff --git a/decompressor.cpp b/decompressor.cpp index 04251c12a..108a774d3 100644 --- a/decompressor.cpp +++ b/decompressor.cpp @@ -12,8 +12,8 @@ * (at your option) any later version. * ***************************************************************************/ -#include "mobipocket.h" #include "decompressor.h" +#include "mobipocket.h" #include @@ -58,7 +58,7 @@ class BitReader public: BitReader(const QByteArray& d) : pos(0), data(d) { - data.append("\000\000\000\000"); + data.append("\000\000\000\000"); //krazy:exclude=strings len=data.size()*8; } @@ -176,8 +176,8 @@ HuffdicDecompressor::HuffdicDecompressor(const PDB& p) : Decompressor(p) off1=readBELong(huff1,16); off2=readBELong(huff1,20); - if (!huff1.startsWith("HUFF")) goto fail; - if (!dicts[0].startsWith("CDIC")) goto fail; + if (!huff1.startsWith("HUFF")) goto fail; //krazy:exclude=strings + if (!dicts[0].startsWith("CDIC")) goto fail; //krazy:exclude=strings entry_bits=readBELong(dicts[0],12); diff --git a/generator_mobi.h b/generator_mobi.h index 94b3cf3bd..db4a2b727 100644 --- a/generator_mobi.h +++ b/generator_mobi.h @@ -6,8 +6,8 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ -#ifndef _OKULAR_GENERATOR_MOBI_H_ -#define _OKULAR_GENERATOR_MOBI_H_ +#ifndef OKULAR_GENERATOR_MOBI_H +#define OKULAR_GENERATOR_MOBI_H #include class MobiGenerator : public Okular::TextDocumentGenerator diff --git a/mobiendanalyzer.cpp b/mobiendanalyzer.cpp index 75008a8e6..0d4fc3da5 100644 --- a/mobiendanalyzer.cpp +++ b/mobiendanalyzer.cpp @@ -67,7 +67,7 @@ MobiEndAnalyzerFactory::registerFields(FieldRegister& reg) { MobiEndAnalyzer::MobiEndAnalyzer(const MobiEndAnalyzerFactory* f) :factory(f) { } bool -MobiEndAnalyzer::checkHeader(const char* header, int32_t headersize) const { +MobiEndAnalyzer::checkHeader(const char* header, int32_t headersize) const { //krazy:exclude=typedefs static const char magic1[] = "TEXtREAd"; static const char magic2[] = "BOOKMOBI"; return headersize >= 67 && (!memcmp(header+60, magic1, 8) || !memcmp(header+60, magic2, 8)); diff --git a/mobiendanalyzer.h b/mobiendanalyzer.h index 72de1df66..c289c9367 100644 --- a/mobiendanalyzer.h +++ b/mobiendanalyzer.h @@ -17,7 +17,7 @@ class MobiEndAnalyzerFactory; class MobiEndAnalyzer : public Strigi::StreamEndAnalyzer { private: const MobiEndAnalyzerFactory* factory; - bool checkHeader(const char* header, int32_t headersize) const; + bool checkHeader(const char* header, int32_t headersize) const; //krazy:exclude=typedefs signed char analyze(Strigi::AnalysisResult& idx, Strigi::InputStream* in); const char* name() const { return "MobiEndAnalyzer"; } public: diff --git a/mobipocket.cpp b/mobipocket.cpp index 7d7b5927d..ee8c8baea 100644 --- a/mobipocket.cpp +++ b/mobipocket.cpp @@ -251,7 +251,7 @@ QString Document::text(int size) const whole+=d->dec->decompress(d->pdb.getRecord(i)); if (!d->dec->isValid()) { d->valid=false; - return QString::null; + return QString(); } if (size!=-1 && whole.size()>size) break; } From 3e468e8c8966b5cd2216f7c4a03c9c36913398da Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Fri, 16 Jan 2009 13:35:34 +0000 Subject: [PATCH 32/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=911993 --- okularApplication_mobi.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index b16658021..fa374da1a 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -6,6 +6,7 @@ Name[hi]=ऑकुलर Name[pa]=ਓਕੁਲਾਰ Name[x-test]=xxOkularxx GenericName=Document Viewer +GenericName[cs]=Prohlížeč dokumentů GenericName[de]=Dokumentenbetrachter GenericName[el]=Προβολέας εγγράφου GenericName[es]=Visor de documentos From 5fd1f8e484a27595257628a48c3d9dbbe1843ab3 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Sat, 17 Jan 2009 15:11:13 +0000 Subject: [PATCH 33/48] Protect against links pointing to after end of the document svn path=/trunk/playground/graphics/okular/mobipocket/; revision=912501 --- mobidocument.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobidocument.cpp b/mobidocument.cpp index d4e9071f2..354f50c09 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -76,6 +76,8 @@ QString MobiDocument::fixMobiMarkup(const QString& data) QMapIterator it(anchorPositions); while (it.hasNext()) { it.next(); + // link pointing outside the document + if ( (it.key()+offset) >= ret.size()) continue; int fixedpos=outsideTag(ret, it.key()+offset); ret.insert(fixedpos,QString("")); offset+=12+it.value().size(); From f03beb39b0d32647c4163a6a4f95608ffbda4d95 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Wed, 21 Jan 2009 13:45:30 +0000 Subject: [PATCH 34/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/playground/graphics/okular/mobipocket/; revision=914658 --- libokularGenerator_mobi.desktop | 2 ++ mobithumbnail.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index abc373091..a81ba4dd3 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -4,6 +4,7 @@ Name=Mobipocket document Name[de]=Mobipocket-Dokument Name[el]=Έγγραφο Mobipocket Name[es]=Documento Mobipocket +Name[et]=Mobipocketi dokument Name[fr]=Document Mobipocket Name[gl]=Documento Mobipocket Name[km]=ឯកសារ Mobipocket @@ -17,6 +18,7 @@ Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[es]=Motor Mobipocket para Okular +Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular Comment[gl]=Infrastrutura de Mobipocket para Okular Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop index 8be2ef82c..94460ebdf 100644 --- a/mobithumbnail.desktop +++ b/mobithumbnail.desktop @@ -3,6 +3,7 @@ Type=Service Name=Mobipocket thumbnailer Name[el]=Εικόνες επισκόπησης Mobipocket Name[es]=Miniaturas para Mobipocket +Name[et]=Mobipocketi pisipildid Name[fr]=Afficheur d'aperçus Mobipocket Name[gl]=Miniaturas para Mobipocket Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket From 124feacd06fa040c542072ab66ed450e8d09f695 Mon Sep 17 00:00:00 2001 From: Jakub Stachowski Date: Mon, 26 Jan 2009 18:11:42 +0000 Subject: [PATCH 35/48] Split into directories Convert svn path=/trunk/playground/graphics/okular/mobipocket/okular/; revision=917031 --- CMakeLists.txt | 66 --------- Messages.sh | 2 - TODO | 3 - converter.cpp | 4 +- converter.h | 4 +- decompressor.cpp | 242 --------------------------------- decompressor.h | 33 ----- mobidocument.cpp | 27 ++-- mobiendanalyzer.cpp | 112 --------------- mobiendanalyzer.h | 47 ------- mobipocket.cpp | 300 ----------------------------------------- mobipocket.h | 66 --------- mobithumbnail.cpp | 40 ------ mobithumbnail.desktop | 21 --- mobithumbnail.h | 23 ---- qfilestream.h | 29 ---- x-mobipocket-ebook.xml | 12 -- 17 files changed, 19 insertions(+), 1012 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100755 Messages.sh delete mode 100644 TODO delete mode 100644 decompressor.cpp delete mode 100644 decompressor.h delete mode 100644 mobiendanalyzer.cpp delete mode 100644 mobiendanalyzer.h delete mode 100644 mobipocket.cpp delete mode 100644 mobipocket.h delete mode 100644 mobithumbnail.cpp delete mode 100644 mobithumbnail.desktop delete mode 100644 mobithumbnail.h delete mode 100644 qfilestream.h delete mode 100644 x-mobipocket-ebook.xml diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 4b5689304..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -CMAKE_MINIMUM_REQUIRED( VERSION 2.6 ) - - -project(okular-mobi-generator) - -ENABLE_TESTING() - -find_package(KDE4 REQUIRED) -find_package(Strigi REQUIRED) -include_directories(${KDE4_INCLUDES} ${QT_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR} - ${STRIGI_INCLUDE_DIR} - ) - -########### next target ############### - -find_package(SharedMimeInfo REQUIRED) - - -set(okularGenerator_mobi_PART_SRCS - converter.cpp - mobipocket.cpp - decompressor.cpp - mobidocument.cpp - generator_mobi.cpp -) - -set(mobithumbnail_SRCS - mobipocket.cpp - decompressor.cpp - mobithumbnail.cpp -) - -set(mobianalyzer_SRCS - mobipocket.cpp - decompressor.cpp - mobiendanalyzer.cpp -) - -kde4_add_plugin(okularGenerator_mobi ${okularGenerator_mobi_PART_SRCS}) -kde4_add_plugin(mobithumbnail ${mobithumbnail_SRCS}) -kde4_add_library(mobi MODULE ${mobianalyzer_SRCS}) - -# FIXME: remove QtGui dependency on analyzer - -target_link_libraries(mobi ${STRIGI_STREAMS_LIBRARY} ${STRIGI_STREAMANALYZER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) -target_link_libraries(okularGenerator_mobi okularcore ${mobi_LIBRARIES} ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY}) -target_link_libraries(mobithumbnail ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY} ) - -install(TARGETS mobithumbnail okularGenerator_mobi DESTINATION ${PLUGIN_INSTALL_DIR}) - -# install the module in the right directory so it is picked up -set_target_properties(mobi PROPERTIES PREFIX ${STRIGI_LINE_ANALYZER_PREFIX}) - - -########### install files ############### - -install( FILES mobithumbnail.desktop libokularGenerator_mobi.desktop okularMobi.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES okularApplication_mobi.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) -install(TARGETS mobi LIBRARY DESTINATION ${LIB_INSTALL_DIR}/strigi) - -install( - FILES x-mobipocket-ebook.xml - DESTINATION ${XDG_MIME_INSTALL_DIR} -) -update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR}) diff --git a/Messages.sh b/Messages.sh deleted file mode 100755 index 48b9406a4..000000000 --- a/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -$XGETTEXT $(find . -name "*.cpp") -o $podir/okular_mobi.pot diff --git a/TODO b/TODO deleted file mode 100644 index db0e6800f..000000000 --- a/TODO +++ /dev/null @@ -1,3 +0,0 @@ -- better error handling -- tests for Mobipocket classes -- decryption for DRMed files (may be impossible and/or illegal) diff --git a/converter.cpp b/converter.cpp index 7012d5c40..76097703c 100644 --- a/converter.cpp +++ b/converter.cpp @@ -7,7 +7,7 @@ * (at your option) any later version. * ***************************************************************************/ -#include "converter.h" +#include "okular/converter.h" #include #include @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/converter.h b/converter.h index 038fcc444..217da4378 100644 --- a/converter.h +++ b/converter.h @@ -12,8 +12,8 @@ #include #include -#include "mobidocument.h" -#include "mobipocket.h" +#include "okular/mobidocument.h" +#include "lib/mobipocket.h" namespace Mobi { diff --git a/decompressor.cpp b/decompressor.cpp deleted file mode 100644 index 108a774d3..000000000 --- a/decompressor.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * RLE decompressor based on FBReader * - * Copyright (C) 2004-2008 Geometer Plus * - * * - * Huffdic decompressor based on Python code by Igor Skochinsky * - * * - * 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. * - ***************************************************************************/ - -#include "decompressor.h" -#include "mobipocket.h" - -#include - -static unsigned char TOKEN_CODE[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; - -namespace Mobipocket { - -class NOOPDecompressor : public Decompressor -{ -public: - NOOPDecompressor(const PDB& p) : Decompressor(p) {} - QByteArray decompress(const QByteArray& data) { return data; } -}; - - -class RLEDecompressor : public Decompressor -{ -public: - RLEDecompressor(const PDB& p) : Decompressor(p) {} - QByteArray decompress(const QByteArray& data); -}; - -class BitReader -{ -public: - BitReader(const QByteArray& d) : pos(0), data(d) - { - data.append("\000\000\000\000"); //krazy:exclude=strings - len=data.size()*8; - } - - quint32 read() { - quint32 g=0; - quint64 r=0; - while (g<32) { - r=(r << 8) | (quint8)data[(pos+g)>>3]; - g=g+8 - ((pos+g) & 7); - } - return (r >> (g-32)); - } - bool eat(int n) { - pos+=n; - return pos <= len; - } - - int left() { - return len - pos; - } - -private: - int pos; - int len; - QByteArray data; -}; - -class HuffdicDecompressor : public Decompressor -{ -public: - HuffdicDecompressor(const PDB& p); - QByteArray decompress(const QByteArray& data); -private: - void unpack(BitReader reader, int depth = 0); - QList dicts; - quint32 entry_bits; - quint32 dict1[256]; - quint32 dict2[64]; - - QByteArray buf; -}; - - - -QByteArray RLEDecompressor::decompress(const QByteArray& data) -{ - QByteArray ret; - ret.reserve(8192); - - unsigned char token; - unsigned short copyLength, N, shift; - unsigned short shifted; - int i=0; - int maxIndex=data.size()-1; - - while (i maxIndex) ) { - goto endOfLoop; - } - ret.append(data.mid(i,token)); - i+=token; - break; - case 2: - ret.append(' '); - ret.append(token ^ 0x80); - break; - case 3: - if (i + 1 > maxIndex) { - goto endOfLoop; - } - N = token; - N<<=8; - N+=(unsigned char)data.at(i++); - copyLength = (N & 7) + 3; - shift = (N & 0x3fff) / 8; - shifted = ret.size()-shift; - if (shifted>(ret.size()-1)) goto endOfLoop; - for (int i=0;i32) goto fail; - while (reader.left()) { - quint32 dw=reader.read(); - quint32 v=dict1[dw>>24]; - quint8 codelen = v & 0x1F; - if (!codelen) goto fail; - quint32 code = dw >> (32 - codelen); - quint32 r=(v >> 8); - if (!( v & 0x80)) { - while (code < dict2[(codelen-1)*2]) { - codelen++; - code = dw >> (32 - codelen); - } - r = dict2[(codelen-1)*2+1]; - } - r-=code; - if (!codelen) goto fail; - if (!reader.eat(codelen)) return; - quint32 dict_no = r >> entry_bits; - quint32 off1 = 16 + (r - (dict_no << entry_bits))*2; - QByteArray dict=dicts[dict_no]; - quint32 off2 = 16 + (unsigned char)dict[off1]*256 + (unsigned char)dict[off1+1]; - quint32 blen = (unsigned char)dict[off2]*256 + (unsigned char)dict[off2+1]; - QByteArray slice=dict.mid(off2+2,(blen & 0x7fff)); - if (blen & 0x8000) buf+=slice; - else unpack(BitReader(slice),depth+1); - } - return; -fail: - valid=false; -} - -Decompressor* Decompressor::create(quint8 type, const PDB& pdb) -{ - switch (type) { - case 1 : return new NOOPDecompressor(pdb); - case 2 : return new RLEDecompressor(pdb); - case 'H' : return new HuffdicDecompressor(pdb); - default : return 0; - } - -} -} diff --git a/decompressor.h b/decompressor.h deleted file mode 100644 index a72f27d4c..000000000 --- a/decompressor.h +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#ifndef MOBI_DECOMPRESSOR_H -#define MOBI_DECOMPRESSOR_H - -#include -namespace Mobipocket { - -class PDB; - -class Decompressor { -public: - Decompressor(const PDB& p) : pdb(p), valid(true) {} - virtual QByteArray decompress(const QByteArray& data) = 0; - virtual ~Decompressor() {} - bool isValid() const { return valid; } - - static Decompressor* create(quint8 type, const PDB& pdb); -protected: - const PDB& pdb; - bool valid; -}; - -quint32 readBELong(const QByteArray& data, int offset); -} -#endif diff --git a/mobidocument.cpp b/mobidocument.cpp index 354f50c09..1310456dc 100644 --- a/mobidocument.cpp +++ b/mobidocument.cpp @@ -6,9 +6,9 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ -#include "mobidocument.h" -#include "mobipocket.h" -#include "qfilestream.h" +#include "okular/mobidocument.h" +#include "lib/mobipocket.h" +#include "lib/qfilestream.h" #include #include #include @@ -54,12 +54,7 @@ int outsideTag(const QString& data, int pos) QString MobiDocument::fixMobiMarkup(const QString& data) { - static QRegExp imgs("", Qt::CaseInsensitive); - - imgs.setMinimal(true); QString ret=data; - ret.replace(imgs,""); - //ret.replace("","

"); QMap anchorPositions; static QRegExp anchors(" it(anchorPositions); while (it.hasNext()) { it.next(); - // link pointing outside the document + // link pointing outside the document, ignore if ( (it.key()+offset) >= ret.size()) continue; int fixedpos=outsideTag(ret, it.key()+offset); - ret.insert(fixedpos,QString("
")); - offset+=12+it.value().size(); + ret.insert(fixedpos,QString(" ")); + // inserting anchor shifts all offsets after the anchor + offset+=21+it.value().size(); } // replace links referencing filepos with normal internal links ret.replace(anchors," where recindex is number of + // record containing image + static QRegExp imgs("", Qt::CaseInsensitive); + + imgs.setMinimal(true); + ret.replace(imgs,""); + ret.replace("","

"); return ret; } diff --git a/mobiendanalyzer.cpp b/mobiendanalyzer.cpp deleted file mode 100644 index 0d4fc3da5..000000000 --- a/mobiendanalyzer.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - - -#include "mobiendanalyzer.h" - -#define STRIGI_IMPORT_API -#include -#include -#include -#include -#include -#include - -#include "mobipocket.h" - -using namespace Strigi; - -class StrigiStream : public Mobipocket::Stream -{ -public: - StrigiStream(InputStream* str) : d(str) {} - int read(char* buf, int len) { - const char* b2; - int l=d->read(b2, len,len); - memcpy(buf,b2,len); - return l; - } - bool seek(int pos) { d->reset(pos); return (pos==d->position()); } -private: - InputStream *d; -}; - -void -MobiEndAnalyzerFactory::registerFields(FieldRegister& reg) { - subjectField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#subject"); - titleField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#title"); - authorField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#author"); - descriptionField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#description"); - copyrightField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#copyright"); - encryptedField = reg.registerField( - "http://freedesktop.org/standards/xesam/1.0/core#isContentEncrypted"); -// typeField = reg.typeField; - //FIXME: check other fields - for example encryption - - /* add the fields to the internal list of fields */ - addField(subjectField); - addField(titleField); - addField(authorField); - addField(descriptionField); - addField(copyrightField); - addField(encryptedField); -// addField(typeField); -} - -MobiEndAnalyzer::MobiEndAnalyzer(const MobiEndAnalyzerFactory* f) :factory(f) { -} -bool -MobiEndAnalyzer::checkHeader(const char* header, int32_t headersize) const { //krazy:exclude=typedefs - static const char magic1[] = "TEXtREAd"; - static const char magic2[] = "BOOKMOBI"; - return headersize >= 67 && (!memcmp(header+60, magic1, 8) || !memcmp(header+60, magic2, 8)); -} - -signed char -MobiEndAnalyzer::analyze(AnalysisResult& as, InputStream* in) { - StrigiStream str(in); - Mobipocket::Document doc(&str); - if (!doc.isValid()) return -1; -// as.addValue(factory->typeField, "http://freedesktop.org/standards/xesam/1.0/core#Document"); - as.addValue(factory->encryptedField, doc.hasDRM()); - QMapIterator it(doc.metadata()); - while (it.hasNext()) { - it.next(); - switch (it.key()) { - case Mobipocket::Document::Title: as.addValue(factory->titleField, it.value().toUtf8().data() ); break; - case Mobipocket::Document::Author: as.addValue(factory->authorField, it.value().toUtf8().data() ); break; - case Mobipocket::Document::Description: as.addValue(factory->descriptionField, it.value().toUtf8().data() ); break; - case Mobipocket::Document::Subject: as.addValue(factory->subjectField, it.value().toUtf8().data() ); break; - case Mobipocket::Document::Copyright: as.addValue(factory->copyrightField, it.value().toUtf8().data() ); break; - } - } - if (!doc.hasDRM()) { - QByteArray text=doc.text(20480).toUtf8(); - as.addText(text.data(), text.size()); - } - return 0; -} - -class Factory : public AnalyzerFactoryFactory -{ -public: - std::list - streamEndAnalyzerFactories() const { - std::list af; - af.push_back(new MobiEndAnalyzerFactory()); - return af; - } -}; - -STRIGI_ANALYZER_FACTORY(Factory) diff --git a/mobiendanalyzer.h b/mobiendanalyzer.h deleted file mode 100644 index c289c9367..000000000 --- a/mobiendanalyzer.h +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#ifndef MOBIENDANALYZER -#define MOBIENDANALYZER - -#include -#include - -class MobiEndAnalyzerFactory; -class MobiEndAnalyzer : public Strigi::StreamEndAnalyzer { -private: - const MobiEndAnalyzerFactory* factory; - bool checkHeader(const char* header, int32_t headersize) const; //krazy:exclude=typedefs - signed char analyze(Strigi::AnalysisResult& idx, Strigi::InputStream* in); - const char* name() const { return "MobiEndAnalyzer"; } -public: - MobiEndAnalyzer(const MobiEndAnalyzerFactory* f); -}; - -class MobiEndAnalyzerFactory : public Strigi::StreamEndAnalyzerFactory { -friend class MobiEndAnalyzer; -private: - const Strigi::RegisteredField* titleField; - const Strigi::RegisteredField* authorField; - const Strigi::RegisteredField* copyrightField; - const Strigi::RegisteredField* subjectField; - const Strigi::RegisteredField* descriptionField; - const Strigi::RegisteredField* encryptedField; -// const Strigi::RegisteredField* typeField; - - const char* name() const { - return "MobiEndAnalyzer"; - } - Strigi::StreamEndAnalyzer* newInstance() const { - return new MobiEndAnalyzer(this); - } - void registerFields(Strigi::FieldRegister&); -}; - -#endif diff --git a/mobipocket.cpp b/mobipocket.cpp deleted file mode 100644 index ee8c8baea..000000000 --- a/mobipocket.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#include "mobipocket.h" -#include "decompressor.h" - -#include -#include -#include -#include -#include - -namespace Mobipocket { - -QByteArray Stream::read(int len) -{ - QByteArray ret; - ret.resize(len); - len=read(ret.data(),len); - if (len<0) len=0; - ret.resize(len); - return ret; -} - -QByteArray Stream::readAll() -{ - QByteArray ret, bit; - while (!(bit=read(4096)).isEmpty()) ret+=bit; - return ret; -} - - - -struct PDBPrivate { - QList recordOffsets; - Stream* device; - QString fileType; - quint16 nrecords; - bool valid; - - void init(); -}; - -void PDBPrivate::init() -{ - valid=true; - quint16 word; - quint32 dword; - if (!device->seek(0x3c)) goto fail; - fileType=QString::fromLatin1(device->read(8)); - - if (!device->seek(0x4c)) goto fail; - device->read((char*)&word,2); - nrecords=qFromBigEndian(word); - - for (int i=0;iread((char*)&dword,4); - recordOffsets.append(qFromBigEndian(dword)); - device->read((char*)&dword,4); - } - return; - fail: - valid=false; -} - -PDB::PDB(Stream* dev) : d(new PDBPrivate) -{ - d->device=dev; - d->init(); -} - -QByteArray PDB::getRecord(int i) const -{ - if (i>=d->nrecords) return QByteArray(); - quint32 offset=d->recordOffsets[i]; - bool last=(i==(d->nrecords-1)); - if (!d->device->seek(offset)) return QByteArray(); - if (last) return d->device->readAll(); - return d->device->read(d->recordOffsets[i+1]-offset); -} - -bool PDB::isValid() const -{ - return d->valid; -} - -int PDB::recordCount() const -{ - return d->nrecords; -} - -//////////////////////////////////////////// -struct DocumentPrivate -{ - DocumentPrivate(Stream* d) : pdb(d), valid(true), firstImageRecord(0), isUtf(false), - drm(false), thumbnailIndex(0) {} - PDB pdb; - Decompressor* dec; - quint16 ntextrecords; - bool valid; - - // number of first record holding image. Usually it is directly after end of text, but not always - quint16 firstImageRecord; - QMap metadata; - bool isUtf; - bool drm; - - // index of thumbnail in image list. May be specified in EXTH. - // If not then just use first image and hope for the best - int thumbnailIndex; - - void init(); - void findFirstImage(); - void parseEXTH(const QByteArray& data); - void parseHtmlHead(const QString& data); - QString readEXTHRecord(const QByteArray& data, quint32& offset); - QString decodeString(const QByteArray& data) const; - QImage getImageFromRecord(int recnum); -}; - -QString DocumentPrivate::decodeString(const QByteArray& data) const -{ - return isUtf ? QString::fromUtf8(data) : QString::fromLatin1(data); -} - -void DocumentPrivate::parseHtmlHead(const QString& data) -{ - static QRegExp title("(.*)", Qt::CaseInsensitive); - static QRegExp author("(.*)", Qt::CaseInsensitive); - static QRegExp copyright("(.*)", Qt::CaseInsensitive); - static QRegExp subject("(.*)", Qt::CaseInsensitive); - static QRegExp description("(.*)", Qt::CaseInsensitive); - title.setMinimal(true); - author.setMinimal(true); - copyright.setMinimal(true); - subject.setMinimal(true); - description.setMinimal(true); - - // title could have been already taken from MOBI record - if (!metadata.contains(Document::Title) && title.indexIn(data)!=-1) metadata[Document::Title]=title.capturedTexts()[1]; - if (author.indexIn(data)!=-1) metadata[Document::Author]=author.capturedTexts()[1]; - if (copyright.indexIn(data)!=-1) metadata[Document::Copyright]=copyright.capturedTexts()[1]; - if (subject.indexIn(data)!=-1) metadata[Document::Subject]=subject.capturedTexts()[1]; - if (description.indexIn(data)!=-1) metadata[Document::Description]=description.capturedTexts()[1]; - -} - -void DocumentPrivate::init() -{ - quint32 encoding; - - valid=pdb.isValid(); - if (!valid) return; - QByteArray mhead=pdb.getRecord(0); - if (mhead.isNull()) goto fail; - dec = Decompressor::create(mhead[1], pdb); - if ((int)mhead[12]!=0 || (int)mhead[13]!=0) drm=true; - if (!dec) goto fail; - - ntextrecords=(unsigned char)mhead[8]; - ntextrecords<<=8; - ntextrecords+=(unsigned char)mhead[9]; - encoding=readBELong(mhead, 28); - if (encoding==65001) isUtf=true; - if (mhead.size()>176) parseEXTH(mhead); - - // try getting metadata from HTML if nothing or only title was recovered from MOBI and EXTH records - if (metadata.size()<2 && !drm) parseHtmlHead(decodeString(dec->decompress(pdb.getRecord(1)))); - return; -fail: - valid=false; -} - -void DocumentPrivate::findFirstImage() { - firstImageRecord=ntextrecords+1; - while (firstImageRecord=92) { - qint32 nameoffset=readBELong(data,84); - qint32 namelen=readBELong(data,88); - if ( (nameoffset + namelen) < data.size() ) { - metadata[Document::Title]=decodeString(data.mid(nameoffset, namelen)); - } - } - - quint32 exthoffs=readBELong(data,20)+16; - - if (data.mid(exthoffs,4)!="EXTH") return; - quint32 records=readBELong(data,exthoffs+8); - quint32 offset=exthoffs+12; - for (unsigned int i=0;iinit(); -} - -QString Document::text(int size) const -{ - QByteArray whole; - for (int i=1;intextrecords+1;i++) { - whole+=d->dec->decompress(d->pdb.getRecord(i)); - if (!d->dec->isValid()) { - d->valid=false; - return QString(); - } - if (size!=-1 && whole.size()>size) break; - } - return d->decodeString(whole); -} - -int Document::imageCount() const -{ - //FIXME: don't count FLIS and FCIS records - return d->pdb.recordCount()-d->ntextrecords; -} - -bool Document::isValid() const -{ - return d->valid; -} - -QImage Document::getImage(int i) const -{ - if (!d->firstImageRecord) d->findFirstImage(); - return d->getImageFromRecord(d->firstImageRecord+i); -} - -QMap Document::metadata() const -{ - return d->metadata; -} - -bool Document::hasDRM() const -{ - return d->drm; -} - -QImage Document::thumbnail() const -{ - if (!d->firstImageRecord) d->findFirstImage(); - QImage img=d->getImageFromRecord(d->thumbnailIndex+d->firstImageRecord); - // does not work, try first image - if (img.isNull() && d->thumbnailIndex) { - d->thumbnailIndex=0; - img=d->getImageFromRecord(d->firstImageRecord); - } - return img; -} - -} diff --git a/mobipocket.h b/mobipocket.h deleted file mode 100644 index 85c798a5a..000000000 --- a/mobipocket.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#ifndef MOBIPOCKET_H -#define MOBIPOCKET_H - -#include -#include -#include -#include - -class QIODevice; - -namespace Mobipocket { - -/** -Minimalistic stream abstraction. It is supposed to allow mobipocket document classes to be -used with both QIODevice (for Okular generator) and InputStream for Strigi analyzer. -*/ -class Stream { -public: - virtual int read(char* buf, int size)=0; - virtual bool seek(int pos)=0; - - QByteArray readAll(); - QByteArray read(int len); - virtual ~Stream() {} -}; - -struct PDBPrivate; -class PDB { -public: - PDB(Stream* s); - QString fileType() const; - int recordCount() const; - QByteArray getRecord(int i) const; - bool isValid() const; -private: - PDBPrivate* const d; -}; - -struct DocumentPrivate; -class Document { -public: - enum MetaKey { Title, Author, Copyright, Description, Subject }; - Document(Stream* s); - QMap metadata() const; - QString text(int size=-1) const; - int imageCount() const; - QImage getImage(int i) const; - QImage thumbnail() const; - bool isValid() const; - - // if true then it is impossible to get text of book. Images should still be readable - bool hasDRM() const; -private: - DocumentPrivate* const d; -}; -} -#endif diff --git a/mobithumbnail.cpp b/mobithumbnail.cpp deleted file mode 100644 index a9e18db9b..000000000 --- a/mobithumbnail.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#include "mobithumbnail.h" -#include "mobipocket.h" -#include "qfilestream.h" - -#include - -extern "C" -{ - KDE_EXPORT ThumbCreator *new_creator() - { - return new MobiThumbnail; - } -} - -bool MobiThumbnail::create(const QString &path, int width, int height, QImage &img) -{ - Q_UNUSED(width); - Q_UNUSED(height); - - Mobipocket::QFileStream f(path); - Mobipocket::Document doc(&f); - if (!doc.isValid()) return false; - img=doc.thumbnail(); - return !img.isNull(); -} - -ThumbCreator::Flags MobiThumbnail::flags() const -{ - return static_cast(None); -} - diff --git a/mobithumbnail.desktop b/mobithumbnail.desktop deleted file mode 100644 index 94460ebdf..000000000 --- a/mobithumbnail.desktop +++ /dev/null @@ -1,21 +0,0 @@ -[Desktop Entry] -Type=Service -Name=Mobipocket thumbnailer -Name[el]=Εικόνες επισκόπησης Mobipocket -Name[es]=Miniaturas para Mobipocket -Name[et]=Mobipocketi pisipildid -Name[fr]=Afficheur d'aperçus Mobipocket -Name[gl]=Miniaturas para Mobipocket -Name[km]=រូបភាព​តូចៗ​របស់ Mobipocket -Name[nds]=Mobipocket-Vöransichten -Name[nl]=Mobipocket-miniatuurmaker -Name[pt]=Miniaturas do Mobipocket -Name[pt_BR]=Miniaturas do Mobipocket -Name[sv]=Skapa Mobipocket-miniatyrbilder -Name[uk]=Інструмент створення мініатюр Mobipocket -Name[x-test]=xxMobipocket thumbnailerxx -X-KDE-ServiceTypes=ThumbCreator -MimeType=application/x-mobipocket-ebook; -X-KDE-Library=mobithumbnail -CacheThumbnail=true - diff --git a/mobithumbnail.h b/mobithumbnail.h deleted file mode 100644 index 78c2d7196..000000000 --- a/mobithumbnail.h +++ /dev/null @@ -1,23 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#ifndef MOBITHUMBNAIL_H -#define MOBITHUMBNAIL_H - -#include - -class MobiThumbnail : public ThumbCreator -{ -public: - MobiThumbnail() {} - virtual bool create(const QString &path, int, int, QImage &img); - virtual Flags flags() const; -}; - -#endif diff --git a/qfilestream.h b/qfilestream.h deleted file mode 100644 index 962a5b857..000000000 --- a/qfilestream.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2008 by Jakub Stachowski * - * * - * 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. * - ***************************************************************************/ - -#ifndef QFILESTREAM_H -#define QFILESTREAM_H - -#include -#include "mobipocket.h" - -namespace Mobipocket { - -class QFileStream : public Stream -{ -public: - QFileStream(const QString& name) : d(name) { d.open(QIODevice::ReadOnly); } - int read(char* buf, int size) { return d.read(buf,size); } - bool seek(int pos) { return d.seek(pos); } -private: - QFile d; -}; - -} -#endif diff --git a/x-mobipocket-ebook.xml b/x-mobipocket-ebook.xml deleted file mode 100644 index 8de52fc14..000000000 --- a/x-mobipocket-ebook.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - E-book in Mobipocket format - - - - - - - - From 2cedccbed80e62d433d22c4f971f89c4b39d9910 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Wed, 28 Jan 2009 15:12:06 +0000 Subject: [PATCH 36/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=917808 --- libokularGenerator_mobi.desktop | 27 --------------------------- okularApplication_mobi.desktop | 23 ----------------------- okularMobi.desktop | 3 --- 3 files changed, 53 deletions(-) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index a81ba4dd3..da52a1a64 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,34 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document -Name[de]=Mobipocket-Dokument -Name[el]=Έγγραφο Mobipocket -Name[es]=Documento Mobipocket -Name[et]=Mobipocketi dokument -Name[fr]=Document Mobipocket -Name[gl]=Documento Mobipocket -Name[km]=ឯកសារ Mobipocket -Name[nds]=Mobipocket-Dokment -Name[nl]=Mobipocket-document -Name[pt]=Documento Mobipocket -Name[pt_BR]=Documento Mobipocket -Name[sv]=Mobipocket-dokument -Name[uk]=Документ Mobipocket -Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular -Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular -Comment[es]=Motor Mobipocket para Okular -Comment[et]=Okulari Mobipocketi taustaprogramm -Comment[fr]=Moteur Mobipocket pour Okular -Comment[gl]=Infrastrutura de Mobipocket para Okular -Comment[km]=កម្មវិធី​ផ្នែក​ខាងក្រោយ Mobipocket សម្រាប់ Okular -Comment[nds]=Mobipocket-Hülppropgramm för Okular -Comment[nl]=Mobipocket backend voor Okular -Comment[pt]=Infra-estrutura do Mobipocket para o Okular -Comment[pt_BR]=Infra-estrutura do Mobipocket para o Okular -Comment[sv]=Mobipocket-gränssnitt för Okular -Comment[uk]=Сервер Mobipocket для Okular -Comment[x-test]=xxMobipocket backend for Okularxx X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index fa374da1a..f8c94cd94 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -2,31 +2,8 @@ MimeType=application/x-mobipocket-ebook; Terminal=false Name=Okular -Name[hi]=ऑकुलर -Name[pa]=ਓਕੁਲਾਰ -Name[x-test]=xxOkularxx GenericName=Document Viewer -GenericName[cs]=Prohlížeč dokumentů -GenericName[de]=Dokumentenbetrachter -GenericName[el]=Προβολέας εγγράφου -GenericName[es]=Visor de documentos -GenericName[et]=Dokumendinäitaja -GenericName[fr]=Visionneur de document GenericName[ga]=Amharcán Cáipéisí -GenericName[gl]=Visor de documentos -GenericName[hi]=दस्तावेज़ प्रदर्शक -GenericName[km]=កម្មវិធី​មើល​ឯកសារ -GenericName[nds]=Dokmentkieker -GenericName[nl]=Documentenviewer -GenericName[oc]=Visualizaire de documents -GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ -GenericName[pt]=Visualizador de Documentos -GenericName[pt_BR]=Visualizador de Documentos -GenericName[ro]=Vizualizator documente -GenericName[sv]=Dokumentvisare -GenericName[tr]=Belge Gösterici -GenericName[uk]=Переглядач документів -GenericName[x-test]=xxDocument Viewerxx Exec=okular %U %i -caption "%c" Icon=okular Type=Application diff --git a/okularMobi.desktop b/okularMobi.desktop index d0b6584ba..8b95ee69b 100644 --- a/okularMobi.desktop +++ b/okularMobi.desktop @@ -1,9 +1,6 @@ [Desktop Entry] Icon=okular Name=Okular -Name[hi]=ऑकुलर -Name[pa]=ਓਕੁਲਾਰ -Name[x-test]=xxOkularxx X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart Type=Service From 26540c77ccab1aef62c0e3e25871765ced29fada Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 29 Jan 2009 23:42:37 +0000 Subject: [PATCH 37/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=918494 --- libokularGenerator_mobi.desktop | 4 ++++ okularApplication_mobi.desktop | 1 + 2 files changed, 5 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index da52a1a64..c547221cc 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,7 +1,11 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[ga]=Cáipéis Mobipocket +Name[nl]=Mobipocket-document Comment=Mobipocket backend for Okular +Comment[ga]=Inneall Mobipocket le haghaidh Okular +Comment[nl]=Mobipocket-backend voor Okular X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index f8c94cd94..c084cfaf7 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -4,6 +4,7 @@ Terminal=false Name=Okular GenericName=Document Viewer GenericName[ga]=Amharcán Cáipéisí +GenericName[nl]=Documentviewer Exec=okular %U %i -caption "%c" Icon=okular Type=Application From 8f6afe7804afcd8a8b0e33ac867384f8493ad8dd Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sat, 31 Jan 2009 16:01:11 +0000 Subject: [PATCH 38/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=919245 --- libokularGenerator_mobi.desktop | 6 ++++++ okularApplication_mobi.desktop | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index c547221cc..2801fdbf5 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -3,9 +3,15 @@ Type=Service Name=Mobipocket document Name[ga]=Cáipéis Mobipocket Name[nl]=Mobipocket-document +Name[sv]=Mobipocket-dokument +Name[tr]=Mobipocket belgesi +Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular Comment[nl]=Mobipocket-backend voor Okular +Comment[sv]=Mobipocket-gränssnitt för Okular +Comment[tr]=Okular için Mobipocket arka ucu +Comment[uk]=Сервер Mobipocket для Okular X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index c084cfaf7..5833f0357 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -5,6 +5,11 @@ Name=Okular GenericName=Document Viewer GenericName[ga]=Amharcán Cáipéisí GenericName[nl]=Documentviewer +GenericName[pt]=Visualizador de Documentos +GenericName[pt_BR]=Visualizador de Documentos +GenericName[sv]=Dokumentvisning +GenericName[tr]=Belge Gösterici +GenericName[uk]=Переглядач документів Exec=okular %U %i -caption "%c" Icon=okular Type=Application From 126416d841d61024568071da38de157916028c51 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 1 Feb 2009 16:27:37 +0000 Subject: [PATCH 39/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=919797 --- libokularGenerator_mobi.desktop | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 2801fdbf5..6ce73c8bf 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -3,12 +3,16 @@ Type=Service Name=Mobipocket document Name[ga]=Cáipéis Mobipocket Name[nl]=Mobipocket-document +Name[pt]=Documento Mobipocket +Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular Comment[nl]=Mobipocket-backend voor Okular +Comment[pt]=Interface do Mobipocket para o Okular +Comment[pt_BR]=Interface do Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular From 731d12a812ddd7385d98433a512ea6f861821d42 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 2 Feb 2009 15:39:14 +0000 Subject: [PATCH 40/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=920241 --- libokularGenerator_mobi.desktop | 4 +++- okularApplication_mobi.desktop | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 6ce73c8bf..e0a68ce56 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[fr]=Document mobipocket Name[ga]=Cáipéis Mobipocket Name[nl]=Mobipocket-document Name[pt]=Documento Mobipocket @@ -9,10 +10,11 @@ Name[sv]=Mobipocket-dokument Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular +Comment[fr]=Moteur Mobipocket pour Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular Comment[nl]=Mobipocket-backend voor Okular Comment[pt]=Interface do Mobipocket para o Okular -Comment[pt_BR]=Interface do Mobipocket para o Okular +Comment[pt_BR]=Infra-estrutura Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 5833f0357..32125871c 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -3,10 +3,11 @@ MimeType=application/x-mobipocket-ebook; Terminal=false Name=Okular GenericName=Document Viewer +GenericName[fr]=Visonneuse de document GenericName[ga]=Amharcán Cáipéisí GenericName[nl]=Documentviewer GenericName[pt]=Visualizador de Documentos -GenericName[pt_BR]=Visualizador de Documentos +GenericName[pt_BR]=Visualizador de documentos GenericName[sv]=Dokumentvisning GenericName[tr]=Belge Gösterici GenericName[uk]=Переглядач документів From b24d8a07027307ae64a7d4afd35ea1e8eeeb7475 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Tue, 3 Feb 2009 14:55:37 +0000 Subject: [PATCH 41/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=920644 --- libokularGenerator_mobi.desktop | 2 ++ okularApplication_mobi.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index e0a68ce56..15f502c30 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[et]=Mobipocketi dokument Name[fr]=Document mobipocket Name[ga]=Cáipéis Mobipocket Name[nl]=Mobipocket-document @@ -10,6 +11,7 @@ Name[sv]=Mobipocket-dokument Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Comment=Mobipocket backend for Okular +Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular Comment[nl]=Mobipocket-backend voor Okular diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 32125871c..d3ccf47ac 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -3,6 +3,7 @@ MimeType=application/x-mobipocket-ebook; Terminal=false Name=Okular GenericName=Document Viewer +GenericName[et]=Dokumentide näitaja GenericName[fr]=Visonneuse de document GenericName[ga]=Amharcán Cáipéisí GenericName[nl]=Documentviewer From f017ba235ab748cfb363d559a9bb9a9996d6001c Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 5 Feb 2009 14:14:16 +0000 Subject: [PATCH 42/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=921700 --- libokularGenerator_mobi.desktop | 4 ++++ okularApplication_mobi.desktop | 3 +++ okularMobi.desktop | 1 + 3 files changed, 8 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 15f502c30..13371c6a4 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -4,22 +4,26 @@ Name=Mobipocket document Name[et]=Mobipocketi dokument Name[fr]=Document mobipocket Name[ga]=Cáipéis Mobipocket +Name[nds]=Mobipocket-Dokment Name[nl]=Mobipocket-document Name[pt]=Documento Mobipocket Name[pt_BR]=Documento Mobipocket Name[sv]=Mobipocket-dokument Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket +Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular +Comment[nds]=Mobipocket-Hülppropgramm för Okular Comment[nl]=Mobipocket-backend voor Okular Comment[pt]=Interface do Mobipocket para o Okular Comment[pt_BR]=Infra-estrutura Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular +Comment[x-test]=xxMobipocket backend for Okularxx X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index d3ccf47ac..f221ff48d 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -2,16 +2,19 @@ MimeType=application/x-mobipocket-ebook; Terminal=false Name=Okular +Name[x-test]=xxOkularxx GenericName=Document Viewer GenericName[et]=Dokumentide näitaja GenericName[fr]=Visonneuse de document GenericName[ga]=Amharcán Cáipéisí +GenericName[nds]=Dokmentkieker GenericName[nl]=Documentviewer GenericName[pt]=Visualizador de Documentos GenericName[pt_BR]=Visualizador de documentos GenericName[sv]=Dokumentvisning GenericName[tr]=Belge Gösterici GenericName[uk]=Переглядач документів +GenericName[x-test]=xxDocument Viewerxx Exec=okular %U %i -caption "%c" Icon=okular Type=Application diff --git a/okularMobi.desktop b/okularMobi.desktop index 8b95ee69b..c0b15caa0 100644 --- a/okularMobi.desktop +++ b/okularMobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Icon=okular Name=Okular +Name[x-test]=xxOkularxx X-KDE-ServiceTypes=KParts/ReadOnlyPart X-KDE-Library=okularpart Type=Service From ba56d63b2e433570bedd2dc6944f8492a9ebb3f8 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sat, 7 Feb 2009 16:10:01 +0000 Subject: [PATCH 43/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=922815 --- libokularGenerator_mobi.desktop | 2 ++ okularApplication_mobi.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index 13371c6a4..cf9224e65 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[es]=Documento Mobipocket Name[et]=Mobipocketi dokument Name[fr]=Document mobipocket Name[ga]=Cáipéis Mobipocket @@ -13,6 +14,7 @@ Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Name[x-test]=xxMobipocket documentxx Comment=Mobipocket backend for Okular +Comment[es]=Motor de Mobipocket para Okular Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index f221ff48d..8bf2e108e 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -4,6 +4,7 @@ Terminal=false Name=Okular Name[x-test]=xxOkularxx GenericName=Document Viewer +GenericName[es]=Visor de documentos GenericName[et]=Dokumentide näitaja GenericName[fr]=Visonneuse de document GenericName[ga]=Amharcán Cáipéisí From cf18de29582e5530fea2d2b06f39a34026409da4 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 7 Feb 2009 17:15:24 +0000 Subject: [PATCH 44/48] about data: fix name and catalog name, fix a typo and add copyright for 2009 svn path=/trunk/kdereview/mobipocket/okular/; revision=922849 --- generator_mobi.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator_mobi.cpp b/generator_mobi.cpp index 950dea77e..0e658f15e 100644 --- a/generator_mobi.cpp +++ b/generator_mobi.cpp @@ -15,13 +15,13 @@ static KAboutData createAboutData() { KAboutData aboutData( - "okular_epub", - "okular_epub", + "okular_mobi", + "okular_mobi", ki18n("Mobipocket Backend"), "0.1", - ki18n("An mobipocket backend"), + ki18n("A mobipocket backend"), KAboutData::License_GPL, - ki18n("© 2008 Jakub Stachowski") + ki18n("© 2008-2009 Jakub Stachowski") ); aboutData.addAuthor(ki18n("Jakub Stachowski"), KLocalizedString(), "qbast@go2.pl"); From e8b21a3b4801a1a9056212694d265b7756386d78 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 8 Feb 2009 14:14:27 +0000 Subject: [PATCH 45/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=923260 --- libokularGenerator_mobi.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index cf9224e65..eac84e5af 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -21,7 +21,7 @@ Comment[ga]=Inneall Mobipocket le haghaidh Okular Comment[nds]=Mobipocket-Hülppropgramm för Okular Comment[nl]=Mobipocket-backend voor Okular Comment[pt]=Interface do Mobipocket para o Okular -Comment[pt_BR]=Infra-estrutura Mobipocket para o Okular +Comment[pt_BR]=Infraestrutura Mobipocket para o Okular Comment[sv]=Mobipocket-gränssnitt för Okular Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular From 5c038fd73043783fcf7afb818504c8492270d7f3 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Thu, 12 Feb 2009 13:45:23 +0000 Subject: [PATCH 46/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=925116 --- libokularGenerator_mobi.desktop | 4 ++++ okularApplication_mobi.desktop | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index eac84e5af..b895c7efd 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Type=Service Name=Mobipocket document +Name[el]=Έγγραφο Mobipocket Name[es]=Documento Mobipocket Name[et]=Mobipocketi dokument Name[fr]=Document mobipocket @@ -13,7 +14,9 @@ Name[sv]=Mobipocket-dokument Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Name[x-test]=xxMobipocket documentxx +Name[zh_CN]=Mobipocket 文档 Comment=Mobipocket backend for Okular +Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[es]=Motor de Mobipocket para Okular Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular @@ -26,6 +29,7 @@ Comment[sv]=Mobipocket-gränssnitt för Okular Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular Comment[x-test]=xxMobipocket backend for Okularxx +Comment[zh_CN]=Okular Mobipocket 后端 X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 8bf2e108e..d2d27d2b1 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -4,6 +4,7 @@ Terminal=false Name=Okular Name[x-test]=xxOkularxx GenericName=Document Viewer +GenericName[el]=Προβολέας εγγράφων GenericName[es]=Visor de documentos GenericName[et]=Dokumentide näitaja GenericName[fr]=Visonneuse de document @@ -16,6 +17,7 @@ GenericName[sv]=Dokumentvisning GenericName[tr]=Belge Gösterici GenericName[uk]=Переглядач документів GenericName[x-test]=xxDocument Viewerxx +GenericName[zh_CN]=文档查看器 Exec=okular %U %i -caption "%c" Icon=okular Type=Application From 9b15f42f6f10d8ddb3953dd752410ecf50d2d710 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Sun, 15 Feb 2009 13:08:05 +0000 Subject: [PATCH 47/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=926460 --- libokularGenerator_mobi.desktop | 2 ++ okularApplication_mobi.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index b895c7efd..f1429529d 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -6,6 +6,7 @@ Name[es]=Documento Mobipocket Name[et]=Mobipocketi dokument Name[fr]=Document mobipocket Name[ga]=Cáipéis Mobipocket +Name[ja]=Mobipocket 文書 Name[nds]=Mobipocket-Dokment Name[nl]=Mobipocket-document Name[pt]=Documento Mobipocket @@ -21,6 +22,7 @@ Comment[es]=Motor de Mobipocket para Okular Comment[et]=Okulari Mobipocketi taustaprogramm Comment[fr]=Moteur Mobipocket pour Okular Comment[ga]=Inneall Mobipocket le haghaidh Okular +Comment[ja]=Okular の Mobipocket 用バックエンド Comment[nds]=Mobipocket-Hülppropgramm för Okular Comment[nl]=Mobipocket-backend voor Okular Comment[pt]=Interface do Mobipocket para o Okular diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index d2d27d2b1..6037bd871 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -9,6 +9,7 @@ GenericName[es]=Visor de documentos GenericName[et]=Dokumentide näitaja GenericName[fr]=Visonneuse de document GenericName[ga]=Amharcán Cáipéisí +GenericName[ja]=文書ビューア GenericName[nds]=Dokmentkieker GenericName[nl]=Documentviewer GenericName[pt]=Visualizador de Documentos From 100f198ab275336d24f4609639564fa354c0ab66 Mon Sep 17 00:00:00 2001 From: Script Kiddy Date: Mon, 16 Feb 2009 12:56:05 +0000 Subject: [PATCH 48/48] SVN_SILENT made messages (.desktop file) svn path=/trunk/kdereview/mobipocket/okular/; revision=926936 --- libokularGenerator_mobi.desktop | 2 ++ okularApplication_mobi.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/libokularGenerator_mobi.desktop b/libokularGenerator_mobi.desktop index f1429529d..3844bd508 100644 --- a/libokularGenerator_mobi.desktop +++ b/libokularGenerator_mobi.desktop @@ -16,6 +16,7 @@ Name[tr]=Mobipocket belgesi Name[uk]=Документ Mobipocket Name[x-test]=xxMobipocket documentxx Name[zh_CN]=Mobipocket 文档 +Name[zh_TW]=Mobipocket 文件 Comment=Mobipocket backend for Okular Comment[el]=Σύστημα υποστήριξης Mobipocket για το Okular Comment[es]=Motor de Mobipocket para Okular @@ -32,6 +33,7 @@ Comment[tr]=Okular için Mobipocket arka ucu Comment[uk]=Сервер Mobipocket для Okular Comment[x-test]=xxMobipocket backend for Okularxx Comment[zh_CN]=Okular Mobipocket 后端 +Comment[zh_TW]=Okular 的 Mobipocket 後端介面 X-KDE-ServiceTypes=okular/Generator MimeType=application/x-mobipocket-ebook; X-KDE-Library=okularGenerator_mobi diff --git a/okularApplication_mobi.desktop b/okularApplication_mobi.desktop index 6037bd871..042f25e5d 100644 --- a/okularApplication_mobi.desktop +++ b/okularApplication_mobi.desktop @@ -19,6 +19,7 @@ GenericName[tr]=Belge Gösterici GenericName[uk]=Переглядач документів GenericName[x-test]=xxDocument Viewerxx GenericName[zh_CN]=文档查看器 +GenericName[zh_TW]=文件檢視器 Exec=okular %U %i -caption "%c" Icon=okular Type=Application