summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Toscano <luigi.toscano@tiscali.it>2016-10-29 16:01:04 (GMT)
committerLuigi Toscano <luigi.toscano@tiscali.it>2016-10-29 16:01:15 (GMT)
commitdaa7341c2ba486a212232ad5a81996f158d9be93 (patch)
tree0770973add191429a144758b5dc8c98a70e143bf
parent5cf97d4dd4c0a7d923da350d9babc36860c5e062 (diff)
-rw-r--r--CMakeLists.txt9
-rw-r--r--lib/mobipocket.h3
-rw-r--r--strigi/CMakeLists.txt19
-rw-r--r--strigi/mobiendanalyzer.cpp112
-rw-r--r--strigi/mobiendanalyzer.h47
5 files changed, 2 insertions, 188 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1823efb..0e045e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,15 +27,6 @@ add_subdirectory(lib)
ecm_optional_add_subdirectory(thumbnailers)
-find_package(Strigi)
-set_package_properties(Strigi PROPERTIES DESCRIPTION "Provide a strigi analyser for Mobipocket documents"
- URL "http://strigi.sourceforge.net"
- TYPE OPTIONAL
-)
-if(STRIGI_STREAMS_LIBRARY)
- ecm_optional_add_subdirectory(strigi)
-endif()
-
set(CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/QMobipocket")
ecm_configure_package_config_file(
diff --git a/lib/mobipocket.h b/lib/mobipocket.h
index 07b4b50..e836a31 100644
--- a/lib/mobipocket.h
+++ b/lib/mobipocket.h
@@ -23,7 +23,8 @@ 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.
+used with QIODevice (for Okular generator), and previously also with InputStream for Strigi
+analyzer.
*/
class QMOBIPOCKET_EXPORT Stream {
public:
diff --git a/strigi/CMakeLists.txt b/strigi/CMakeLists.txt
deleted file mode 100644
index 3b6e867..0000000
--- a/strigi/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-include_directories(${STRIGI_INCLUDE_DIR})
-
-########### next target ###############
-
-set(mobianalyzer_SRCS
- mobiendanalyzer.cpp
-)
-
-add_library(mobi MODULE ${mobianalyzer_SRCS})
-
-target_link_libraries(mobi ${STRIGI_STREAMS_LIBRARY} ${STRIGI_STREAMANALYZER_LIBRARY}
- Qt5::Core Qt5::Gui qmobipocket)
-
-# install the module in the right directory so it is picked up
-set_target_properties(mobi PROPERTIES PREFIX strigila_)
-
-########### install files ###############
-
-install(TARGETS mobi LIBRARY DESTINATION ${LIB_INSTALL_DIR}/strigi)
diff --git a/strigi/mobiendanalyzer.cpp b/strigi/mobiendanalyzer.cpp
deleted file mode 100644
index 035620a..0000000
--- a/strigi/mobiendanalyzer.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl> *
- * *
- * 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 <strigi/strigiconfig.h>
-#include <strigi/analysisresult.h>
-#include <strigi/fieldtypes.h>
-#include <strigi/streamendanalyzer.h>
-#include <strigi/analyzerplugin.h>
-#include <list>
-
-#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);
- if (l>0) memcpy(buf,b2,l);
- 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<Mobipocket::Document::MetaKey,QString> 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<StreamEndAnalyzerFactory*>
- streamEndAnalyzerFactories() const {
- std::list<StreamEndAnalyzerFactory*> af;
- af.push_back(new MobiEndAnalyzerFactory());
- return af;
- }
-};
-
-STRIGI_ANALYZER_FACTORY(Factory)
diff --git a/strigi/mobiendanalyzer.h b/strigi/mobiendanalyzer.h
deleted file mode 100644
index c289c93..0000000
--- a/strigi/mobiendanalyzer.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Jakub Stachowski <qbast@go2.pl> *
- * *
- * 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 <strigi/streamendanalyzer.h>
-#include <strigi/streambase.h>
-
-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