mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
"encryption type" => "encryption method"
This commit is contained in:
parent
2f75bb15d6
commit
b52849025a
13 changed files with 45 additions and 28 deletions
|
@ -859,6 +859,7 @@
|
||||||
<node name="pluginNotFound" value="No plugin for '%s'"/>
|
<node name="pluginNotFound" value="No plugin for '%s'"/>
|
||||||
<node name="unknownPluginType" value="Unknown plugin type: %s"/>
|
<node name="unknownPluginType" value="Unknown plugin type: %s"/>
|
||||||
<node name="fileNotFound" value="File not found: %s"/>
|
<node name="fileNotFound" value="File not found: %s"/>
|
||||||
|
<node name="unsupportedEncryptionMethod" value="File %s is encrypted with method that is not supported by FBReader. Some pages are not readable"/>
|
||||||
<node name="opfFileNotFound" value="OPF is not found in %s"/>
|
<node name="opfFileNotFound" value="OPF is not found in %s"/>
|
||||||
<node name="unsupportedFileFormat" value="File format is not supported for '%s'"/>
|
<node name="unsupportedFileFormat" value="File format is not supported for '%s'"/>
|
||||||
<node name="errorParsingRtf" value="Rtf parsing error in: %s"/>
|
<node name="errorParsingRtf" value="Rtf parsing error in: %s"/>
|
||||||
|
|
|
@ -131,14 +131,14 @@ JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT jstring JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readEncryptionType(JNIEnv* env, jobject thiz, jobject javaBook) {
|
JNIEXPORT jstring JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readEncryptionMethod(JNIEnv* env, jobject thiz, jobject javaBook) {
|
||||||
shared_ptr<FormatPlugin> plugin = findCppPlugin(thiz);
|
shared_ptr<FormatPlugin> plugin = findCppPlugin(thiz);
|
||||||
if (plugin.isNull()) {
|
if (plugin.isNull()) {
|
||||||
return AndroidUtil::createJavaString(env, FormatPlugin::EncryptionType::UNKNOWN);
|
return AndroidUtil::createJavaString(env, FormatPlugin::EncryptionMethod::UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Book> book = Book::loadFromJavaBook(env, javaBook);
|
shared_ptr<Book> book = Book::loadFromJavaBook(env, javaBook);
|
||||||
return AndroidUtil::createJavaString(env, plugin->readEncryptionType(*book));
|
return AndroidUtil::createJavaString(env, plugin->readEncryptionMethod(*book));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
|
|
||||||
#include "../library/Book.h"
|
#include "../library/Book.h"
|
||||||
|
|
||||||
const std::string FormatPlugin::EncryptionType::NONE = "none";
|
const std::string FormatPlugin::EncryptionMethod::NONE = "none";
|
||||||
const std::string FormatPlugin::EncryptionType::UNKNOWN = "unknown";
|
const std::string FormatPlugin::EncryptionMethod::UNSUPPORTED = "unsupported";
|
||||||
const std::string FormatPlugin::EncryptionType::MARLIN = "marlin";
|
const std::string FormatPlugin::EncryptionMethod::MARLIN = "marlin";
|
||||||
|
|
||||||
bool FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream, bool force) {
|
bool FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream, bool force) {
|
||||||
std::string language = book.language();
|
std::string language = book.language();
|
||||||
|
@ -103,8 +103,8 @@ const std::string &FormatPlugin::tryOpen(const ZLFile&) const {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &FormatPlugin::readEncryptionType(Book &book) const {
|
const std::string &FormatPlugin::readEncryptionMethod(Book &book) const {
|
||||||
return EncryptionType::NONE;
|
return EncryptionMethod::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<const ZLImage> FormatPlugin::coverImage(const ZLFile &file) const {
|
shared_ptr<const ZLImage> FormatPlugin::coverImage(const ZLFile &file) const {
|
||||||
|
|
|
@ -47,11 +47,11 @@ public:
|
||||||
class FormatPlugin {
|
class FormatPlugin {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class EncryptionType {
|
class EncryptionMethod {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const std::string NONE;
|
static const std::string NONE;
|
||||||
static const std::string UNKNOWN;
|
static const std::string UNSUPPORTED;
|
||||||
static const std::string MARLIN;
|
static const std::string MARLIN;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
|
|
||||||
virtual const std::string &tryOpen(const ZLFile &file) const;
|
virtual const std::string &tryOpen(const ZLFile &file) const;
|
||||||
virtual bool readMetaInfo(Book &book) const = 0;
|
virtual bool readMetaInfo(Book &book) const = 0;
|
||||||
virtual const std::string &readEncryptionType(Book &book) const;
|
virtual const std::string &readEncryptionMethod(Book &book) const;
|
||||||
virtual bool readUids(Book &book) const = 0;
|
virtual bool readUids(Book &book) const = 0;
|
||||||
virtual bool readLanguageAndEncoding(Book &book) const = 0;
|
virtual bool readLanguageAndEncoding(Book &book) const = 0;
|
||||||
virtual bool readModel(BookModel &model) const = 0;
|
virtual bool readModel(BookModel &model) const = 0;
|
||||||
|
|
|
@ -30,17 +30,17 @@ OEBEncryptionReader::OEBEncryptionReader() : myIsMarlin(false) {
|
||||||
const std::string &OEBEncryptionReader::readEncryptionInfo(const ZLFile &epubFile) {
|
const std::string &OEBEncryptionReader::readEncryptionInfo(const ZLFile &epubFile) {
|
||||||
shared_ptr<ZLDir> epubDir = epubFile.directory();
|
shared_ptr<ZLDir> epubDir = epubFile.directory();
|
||||||
if (epubDir.isNull()) {
|
if (epubDir.isNull()) {
|
||||||
return FormatPlugin::EncryptionType::UNKNOWN;
|
return FormatPlugin::EncryptionMethod::UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ZLFile rightsFile(epubDir->itemPath("META-INF/rights.xml"));
|
const ZLFile rightsFile(epubDir->itemPath("META-INF/rights.xml"));
|
||||||
if (rightsFile.exists()) {
|
if (rightsFile.exists()) {
|
||||||
readDocument(rightsFile);
|
readDocument(rightsFile);
|
||||||
return myIsMarlin
|
return myIsMarlin
|
||||||
? FormatPlugin::EncryptionType::MARLIN
|
? FormatPlugin::EncryptionMethod::MARLIN
|
||||||
: FormatPlugin::EncryptionType::UNKNOWN;
|
: FormatPlugin::EncryptionMethod::UNSUPPORTED;
|
||||||
} else {
|
} else {
|
||||||
return FormatPlugin::EncryptionType::NONE;
|
return FormatPlugin::EncryptionMethod::NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ bool OEBPlugin::readMetaInfo(Book &book) const {
|
||||||
return OEBMetaInfoReader(book).readMetaInfo(opfFile(file));
|
return OEBMetaInfoReader(book).readMetaInfo(opfFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &OEBPlugin::readEncryptionType(Book &book) const {
|
const std::string &OEBPlugin::readEncryptionMethod(Book &book) const {
|
||||||
return OEBEncryptionReader().readEncryptionInfo(epubFile(book.file()));
|
return OEBEncryptionReader().readEncryptionInfo(epubFile(book.file()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
bool providesMetaInfo() const;
|
bool providesMetaInfo() const;
|
||||||
const std::string supportedFileType() const;
|
const std::string supportedFileType() const;
|
||||||
bool readMetaInfo(Book &book) const;
|
bool readMetaInfo(Book &book) const;
|
||||||
const std::string &readEncryptionType(Book &book) const;
|
const std::string &readEncryptionMethod(Book &book) const;
|
||||||
bool readUids(Book &book) const;
|
bool readUids(Book &book) const;
|
||||||
bool readLanguageAndEncoding(Book &book) const;
|
bool readLanguageAndEncoding(Book &book) const;
|
||||||
bool readModel(BookModel &model) const;
|
bool readModel(BookModel &model) const;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.geometerplus.zlibrary.text.view.*;
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.bookmodel.*;
|
import org.geometerplus.fbreader.bookmodel.*;
|
||||||
import org.geometerplus.fbreader.fbreader.options.*;
|
import org.geometerplus.fbreader.fbreader.options.*;
|
||||||
|
import org.geometerplus.fbreader.formats.FormatPlugin;
|
||||||
|
|
||||||
public final class FBReaderApp extends ZLApplication {
|
public final class FBReaderApp extends ZLApplication {
|
||||||
public final MiscOptions MiscOptions = new MiscOptions();
|
public final MiscOptions MiscOptions = new MiscOptions();
|
||||||
|
@ -278,6 +279,22 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
|
|
||||||
getViewWidget().reset();
|
getViewWidget().reset();
|
||||||
getViewWidget().repaint();
|
getViewWidget().repaint();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!FormatPlugin.EncryptionMethod.NONE.equals(
|
||||||
|
book.getPlugin().readEncryptionMethod(book))) {
|
||||||
|
System.err.println("UNSUPPORTED ALGORITHM");
|
||||||
|
/*
|
||||||
|
UIUtil.showErrorMessage(
|
||||||
|
FBReader.this,
|
||||||
|
"unsupportedEncryptionAlgorithm",
|
||||||
|
myBook.File.getPath()
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
} catch (BookReadingException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Bookmark> invisibleBookmarks() {
|
private List<Bookmark> invisibleBookmarks() {
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||||
|
|
||||||
public abstract class FormatPlugin {
|
public abstract class FormatPlugin {
|
||||||
public interface EncryptionType {
|
public interface EncryptionMethod {
|
||||||
String NONE = "none";
|
String NONE = "none";
|
||||||
String UNKNOWN = "unknown";
|
String UNSUPPORTED = "unsupported";
|
||||||
String MARLIN = "marlin";
|
String MARLIN = "marlin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public abstract class FormatPlugin {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
public abstract void readMetaInfo(Book book) throws BookReadingException;
|
public abstract void readMetaInfo(Book book) throws BookReadingException;
|
||||||
public abstract String readEncryptionType(Book book);
|
public abstract String readEncryptionMethod(Book book);
|
||||||
public abstract void readUids(Book book) throws BookReadingException;
|
public abstract void readUids(Book book) throws BookReadingException;
|
||||||
public abstract void readModel(BookModel model) throws BookReadingException;
|
public abstract void readModel(BookModel model) throws BookReadingException;
|
||||||
public abstract void detectLanguageAndEncoding(Book book) throws BookReadingException;
|
public abstract void detectLanguageAndEncoding(Book book) throws BookReadingException;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class NativeFormatPlugin extends FormatPlugin {
|
||||||
private native int readMetaInfoNative(Book book);
|
private native int readMetaInfoNative(Book book);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public native String readEncryptionType(Book book);
|
public native String readEncryptionMethod(Book book);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
synchronized public void readUids(Book book) throws BookReadingException {
|
synchronized public void readUids(Book book) throws BookReadingException {
|
||||||
|
@ -83,7 +83,6 @@ public class NativeFormatPlugin extends FormatPlugin {
|
||||||
@Override
|
@Override
|
||||||
synchronized public void readModel(BookModel model) throws BookReadingException {
|
synchronized public void readModel(BookModel model) throws BookReadingException {
|
||||||
final int code = readModelNative(model);
|
final int code = readModelNative(model);
|
||||||
System.err.println("ENCRYPTION TYPE = " + readEncryptionType(model.Book));
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
throw new BookReadingException(
|
throw new BookReadingException(
|
||||||
"nativeCodeFailure",
|
"nativeCodeFailure",
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class FB2Plugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readEncryptionType(Book book) {
|
public String readEncryptionMethod(Book book) {
|
||||||
return EncryptionType.NONE;
|
return EncryptionMethod.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class OEBPlugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readEncryptionType(Book book) {
|
public String readEncryptionMethod(Book book) {
|
||||||
return EncryptionType.NONE;
|
return EncryptionMethod.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -124,8 +124,8 @@ public class MobipocketPlugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readEncryptionType(Book book) {
|
public String readEncryptionMethod(Book book) {
|
||||||
return EncryptionType.NONE;
|
return EncryptionMethod.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue