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="unknownPluginType" value="Unknown plugin type: %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="unsupportedFileFormat" value="File format is not supported for '%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"
|
||||
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);
|
||||
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);
|
||||
return AndroidUtil::createJavaString(env, plugin->readEncryptionType(*book));
|
||||
return AndroidUtil::createJavaString(env, plugin->readEncryptionMethod(*book));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
#include "../library/Book.h"
|
||||
|
||||
const std::string FormatPlugin::EncryptionType::NONE = "none";
|
||||
const std::string FormatPlugin::EncryptionType::UNKNOWN = "unknown";
|
||||
const std::string FormatPlugin::EncryptionType::MARLIN = "marlin";
|
||||
const std::string FormatPlugin::EncryptionMethod::NONE = "none";
|
||||
const std::string FormatPlugin::EncryptionMethod::UNSUPPORTED = "unsupported";
|
||||
const std::string FormatPlugin::EncryptionMethod::MARLIN = "marlin";
|
||||
|
||||
bool FormatPlugin::detectEncodingAndLanguage(Book &book, ZLInputStream &stream, bool force) {
|
||||
std::string language = book.language();
|
||||
|
@ -103,8 +103,8 @@ const std::string &FormatPlugin::tryOpen(const ZLFile&) const {
|
|||
return EMPTY;
|
||||
}
|
||||
|
||||
const std::string &FormatPlugin::readEncryptionType(Book &book) const {
|
||||
return EncryptionType::NONE;
|
||||
const std::string &FormatPlugin::readEncryptionMethod(Book &book) const {
|
||||
return EncryptionMethod::NONE;
|
||||
}
|
||||
|
||||
shared_ptr<const ZLImage> FormatPlugin::coverImage(const ZLFile &file) const {
|
||||
|
|
|
@ -47,11 +47,11 @@ public:
|
|||
class FormatPlugin {
|
||||
|
||||
public:
|
||||
class EncryptionType {
|
||||
class EncryptionMethod {
|
||||
|
||||
public:
|
||||
static const std::string NONE;
|
||||
static const std::string UNKNOWN;
|
||||
static const std::string UNSUPPORTED;
|
||||
static const std::string MARLIN;
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
virtual const std::string &tryOpen(const ZLFile &file) const;
|
||||
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 readLanguageAndEncoding(Book &book) 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) {
|
||||
shared_ptr<ZLDir> epubDir = epubFile.directory();
|
||||
if (epubDir.isNull()) {
|
||||
return FormatPlugin::EncryptionType::UNKNOWN;
|
||||
return FormatPlugin::EncryptionMethod::UNSUPPORTED;
|
||||
}
|
||||
|
||||
const ZLFile rightsFile(epubDir->itemPath("META-INF/rights.xml"));
|
||||
if (rightsFile.exists()) {
|
||||
readDocument(rightsFile);
|
||||
return myIsMarlin
|
||||
? FormatPlugin::EncryptionType::MARLIN
|
||||
: FormatPlugin::EncryptionType::UNKNOWN;
|
||||
? FormatPlugin::EncryptionMethod::MARLIN
|
||||
: FormatPlugin::EncryptionMethod::UNSUPPORTED;
|
||||
} 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));
|
||||
}
|
||||
|
||||
const std::string &OEBPlugin::readEncryptionType(Book &book) const {
|
||||
const std::string &OEBPlugin::readEncryptionMethod(Book &book) const {
|
||||
return OEBEncryptionReader().readEncryptionInfo(epubFile(book.file()));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
bool providesMetaInfo() const;
|
||||
const std::string supportedFileType() 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 readLanguageAndEncoding(Book &book) 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.bookmodel.*;
|
||||
import org.geometerplus.fbreader.fbreader.options.*;
|
||||
import org.geometerplus.fbreader.formats.FormatPlugin;
|
||||
|
||||
public final class FBReaderApp extends ZLApplication {
|
||||
public final MiscOptions MiscOptions = new MiscOptions();
|
||||
|
@ -278,6 +279,22 @@ public final class FBReaderApp extends ZLApplication {
|
|||
|
||||
getViewWidget().reset();
|
||||
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() {
|
||||
|
|
|
@ -28,9 +28,9 @@ import org.geometerplus.fbreader.bookmodel.BookModel;
|
|||
import org.geometerplus.fbreader.bookmodel.BookReadingException;
|
||||
|
||||
public abstract class FormatPlugin {
|
||||
public interface EncryptionType {
|
||||
public interface EncryptionMethod {
|
||||
String NONE = "none";
|
||||
String UNKNOWN = "unknown";
|
||||
String UNSUPPORTED = "unsupported";
|
||||
String MARLIN = "marlin";
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public abstract class FormatPlugin {
|
|||
return file;
|
||||
}
|
||||
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 readModel(BookModel model) 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);
|
||||
|
||||
@Override
|
||||
public native String readEncryptionType(Book book);
|
||||
public native String readEncryptionMethod(Book book);
|
||||
|
||||
@Override
|
||||
synchronized public void readUids(Book book) throws BookReadingException {
|
||||
|
@ -83,7 +83,6 @@ public class NativeFormatPlugin extends FormatPlugin {
|
|||
@Override
|
||||
synchronized public void readModel(BookModel model) throws BookReadingException {
|
||||
final int code = readModelNative(model);
|
||||
System.err.println("ENCRYPTION TYPE = " + readEncryptionType(model.Book));
|
||||
if (code != 0) {
|
||||
throw new BookReadingException(
|
||||
"nativeCodeFailure",
|
||||
|
|
|
@ -48,8 +48,8 @@ public class FB2Plugin extends JavaFormatPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String readEncryptionType(Book book) {
|
||||
return EncryptionType.NONE;
|
||||
public String readEncryptionMethod(Book book) {
|
||||
return EncryptionMethod.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,8 +62,8 @@ public class OEBPlugin extends JavaFormatPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String readEncryptionType(Book book) {
|
||||
return EncryptionType.NONE;
|
||||
public String readEncryptionMethod(Book book) {
|
||||
return EncryptionMethod.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -124,8 +124,8 @@ public class MobipocketPlugin extends JavaFormatPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String readEncryptionType(Book book) {
|
||||
return EncryptionType.NONE;
|
||||
public String readEncryptionMethod(Book book) {
|
||||
return EncryptionMethod.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue