mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
readMetaInfo -> readMetainfo
This commit is contained in:
parent
456a320625
commit
aeb905a08d
29 changed files with 45 additions and 45 deletions
|
@ -94,7 +94,7 @@ static void fillLanguageAndEncoding(JNIEnv* env, jobject javaBook, Book &book) {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readMetaInfoNative(JNIEnv* env, jobject thiz, jobject javaBook) {
|
JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readMetainfoNative(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 1;
|
return 1;
|
||||||
|
@ -102,7 +102,7 @@ JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin
|
||||||
|
|
||||||
shared_ptr<Book> book = Book::loadFromJavaBook(env, javaBook);
|
shared_ptr<Book> book = Book::loadFromJavaBook(env, javaBook);
|
||||||
|
|
||||||
if (!plugin->readMetaInfo(*book)) {
|
if (!plugin->readMetainfo(*book)) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
//virtual FormatInfoPage *createInfoPage(ZLOptionsDialog &dialog, const ZLFile &file);
|
//virtual FormatInfoPage *createInfoPage(ZLOptionsDialog &dialog, const ZLFile &file);
|
||||||
|
|
||||||
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 std::vector<shared_ptr<FileEncryptionInfo> > readEncryptionInfos(Book &book) const;
|
virtual std::vector<shared_ptr<FileEncryptionInfo> > readEncryptionInfos(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;
|
||||||
|
|
|
@ -30,7 +30,7 @@ DocMetaInfoReader::DocMetaInfoReader(Book &book) : myBook(book) {
|
||||||
myBook.removeAllTags();
|
myBook.removeAllTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocMetaInfoReader::readMetaInfo() {
|
bool DocMetaInfoReader::readMetainfo() {
|
||||||
myBook.removeAllAuthors();
|
myBook.removeAllAuthors();
|
||||||
myBook.setTitle(myBook.file().name(true));
|
myBook.setTitle(myBook.file().name(true));
|
||||||
myBook.removeAllTags();
|
myBook.removeAllTags();
|
||||||
|
|
|
@ -29,7 +29,7 @@ class DocMetaInfoReader {
|
||||||
public:
|
public:
|
||||||
DocMetaInfoReader(Book &book);
|
DocMetaInfoReader(Book &book);
|
||||||
~DocMetaInfoReader();
|
~DocMetaInfoReader();
|
||||||
bool readMetaInfo();
|
bool readMetainfo();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void startElementHandler(int tag, const char **attributes);
|
void startElementHandler(int tag, const char **attributes);
|
||||||
|
|
|
@ -48,8 +48,8 @@ bool DocPlugin::acceptsFile(const ZLFile &file) const {
|
||||||
return file.extension() == "doc";
|
return file.extension() == "doc";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocPlugin::readMetaInfo(Book &book) const {
|
bool DocPlugin::readMetainfo(Book &book) const {
|
||||||
if (!DocMetaInfoReader(book).readMetaInfo()) {
|
if (!DocMetaInfoReader(book).readMetainfo()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ void FB2MetaInfoReader::endElementHandler(int tag) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FB2MetaInfoReader::readMetaInfo() {
|
bool FB2MetaInfoReader::readMetainfo() {
|
||||||
myReadState = READ_NOTHING;
|
myReadState = READ_NOTHING;
|
||||||
myBuffer.erase();
|
myBuffer.erase();
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class FB2MetaInfoReader : public FB2Reader {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FB2MetaInfoReader(Book &book);
|
FB2MetaInfoReader(Book &book);
|
||||||
bool readMetaInfo();
|
bool readMetainfo();
|
||||||
|
|
||||||
void startElementHandler(int tag, const char **attributes);
|
void startElementHandler(int tag, const char **attributes);
|
||||||
void endElementHandler(int tag);
|
void endElementHandler(int tag);
|
||||||
|
|
|
@ -30,8 +30,8 @@ const std::string FB2Plugin::supportedFileType() const {
|
||||||
return "fb2";
|
return "fb2";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FB2Plugin::readMetaInfo(Book &book) const {
|
bool FB2Plugin::readMetainfo(Book &book) const {
|
||||||
return FB2MetaInfoReader(book).readMetaInfo();
|
return FB2MetaInfoReader(book).readMetainfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FB2Plugin::readUids(Book &book) const {
|
bool FB2Plugin::readUids(Book &book) const {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
~FB2Plugin();
|
~FB2Plugin();
|
||||||
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;
|
||||||
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,7 +34,7 @@ const std::string HtmlPlugin::supportedFileType() const {
|
||||||
return "HTML";
|
return "HTML";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HtmlPlugin::readMetaInfo(Book &book) const {
|
bool HtmlPlugin::readMetainfo(Book &book) const {
|
||||||
shared_ptr<ZLInputStream> stream = book.file().inputStream();
|
shared_ptr<ZLInputStream> stream = book.file().inputStream();
|
||||||
if (stream.isNull()) {
|
if (stream.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
~HtmlPlugin();
|
~HtmlPlugin();
|
||||||
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;
|
||||||
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;
|
||||||
|
|
|
@ -154,7 +154,7 @@ void OEBMetaInfoReader::endElementHandler(const char *tag) {
|
||||||
myReadState = READ_METADATA;
|
myReadState = READ_METADATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OEBMetaInfoReader::readMetaInfo(const ZLFile &file) {
|
bool OEBMetaInfoReader::readMetainfo(const ZLFile &file) {
|
||||||
myReadState = READ_NONE;
|
myReadState = READ_NONE;
|
||||||
if (!readDocument(file)) {
|
if (!readDocument(file)) {
|
||||||
ZLLogger::Instance().println("epub", "Failure while reading info from " + file.path());
|
ZLLogger::Instance().println("epub", "Failure while reading info from " + file.path());
|
||||||
|
|
|
@ -30,7 +30,7 @@ class OEBMetaInfoReader : public OPFReader {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OEBMetaInfoReader(Book &book);
|
OEBMetaInfoReader(Book &book);
|
||||||
bool readMetaInfo(const ZLFile &file);
|
bool readMetainfo(const ZLFile &file);
|
||||||
|
|
||||||
void startElementHandler(const char *tag, const char **attributes);
|
void startElementHandler(const char *tag, const char **attributes);
|
||||||
void endElementHandler(const char *tag);
|
void endElementHandler(const char *tag);
|
||||||
|
|
|
@ -124,9 +124,9 @@ ZLFile OEBPlugin::opfFile(const ZLFile &oebFile) {
|
||||||
return ZLFile::NO_FILE;
|
return ZLFile::NO_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OEBPlugin::readMetaInfo(Book &book) const {
|
bool OEBPlugin::readMetainfo(Book &book) const {
|
||||||
const ZLFile &file = book.file();
|
const ZLFile &file = book.file();
|
||||||
return OEBMetaInfoReader(book).readMetaInfo(opfFile(file));
|
return OEBMetaInfoReader(book).readMetainfo(opfFile(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<shared_ptr<FileEncryptionInfo> > OEBPlugin::readEncryptionInfos(Book &book) const {
|
std::vector<shared_ptr<FileEncryptionInfo> > OEBPlugin::readEncryptionInfos(Book &book) const {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
~OEBPlugin();
|
~OEBPlugin();
|
||||||
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;
|
||||||
virtual std::vector<shared_ptr<FileEncryptionInfo> > readEncryptionInfos(Book &book) const;
|
virtual std::vector<shared_ptr<FileEncryptionInfo> > readEncryptionInfos(Book &book) const;
|
||||||
bool readUids(Book &book) const;
|
bool readUids(Book &book) const;
|
||||||
bool readLanguageAndEncoding(Book &book) const;
|
bool readLanguageAndEncoding(Book &book) const;
|
||||||
|
|
|
@ -37,7 +37,7 @@ const std::string RtfPlugin::supportedFileType() const {
|
||||||
return "rtf";
|
return "rtf";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtfPlugin::readMetaInfo(Book &book) const {
|
bool RtfPlugin::readMetainfo(Book &book) const {
|
||||||
if (!RtfDescriptionReader(book).readDocument(book.file())) {
|
if (!RtfDescriptionReader(book).readDocument(book.file())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class RtfPlugin : public FormatPlugin {
|
||||||
public:
|
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;
|
||||||
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;
|
||||||
|
|
|
@ -38,7 +38,7 @@ const std::string TxtPlugin::supportedFileType() const {
|
||||||
return "plain text";
|
return "plain text";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TxtPlugin::readMetaInfo(Book &/*book*/) const {
|
bool TxtPlugin::readMetainfo(Book &/*book*/) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
~TxtPlugin();
|
~TxtPlugin();
|
||||||
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;
|
||||||
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;
|
||||||
|
|
|
@ -65,7 +65,7 @@ shared_ptr<Book> Book::loadFromFile(const ZLFile &file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<Book> book = new Book(file, 0);
|
shared_ptr<Book> book = new Book(file, 0);
|
||||||
if (!plugin->readMetaInfo(*book)) {
|
if (!plugin->readMetainfo(*book)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class Book extends TitledEntity {
|
||||||
myId = -1;
|
myId = -1;
|
||||||
final FormatPlugin plugin = getPlugin(file);
|
final FormatPlugin plugin = getPlugin(file);
|
||||||
File = plugin.realBookFile(file);
|
File = plugin.realBookFile(file);
|
||||||
readMetaInfo(plugin);
|
readMetainfo(plugin);
|
||||||
myIsSaved = false;
|
myIsSaved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ public class Book extends TitledEntity {
|
||||||
|
|
||||||
public void reloadInfoFromFile() {
|
public void reloadInfoFromFile() {
|
||||||
try {
|
try {
|
||||||
readMetaInfo();
|
readMetainfo();
|
||||||
} catch (BookReadingException e) {
|
} catch (BookReadingException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
@ -175,11 +175,11 @@ public class Book extends TitledEntity {
|
||||||
return getPlugin(File);
|
return getPlugin(File);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readMetaInfo() throws BookReadingException {
|
void readMetainfo() throws BookReadingException {
|
||||||
readMetaInfo(getPlugin());
|
readMetainfo(getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readMetaInfo(FormatPlugin plugin) throws BookReadingException {
|
private void readMetainfo(FormatPlugin plugin) throws BookReadingException {
|
||||||
myEncoding = null;
|
myEncoding = null;
|
||||||
myLanguage = null;
|
myLanguage = null;
|
||||||
setTitle(null);
|
setTitle(null);
|
||||||
|
@ -190,7 +190,7 @@ public class Book extends TitledEntity {
|
||||||
|
|
||||||
myIsSaved = false;
|
myIsSaved = false;
|
||||||
|
|
||||||
plugin.readMetaInfo(this);
|
plugin.readMetainfo(this);
|
||||||
if (myUids == null || myUids.isEmpty()) {
|
if (myUids == null || myUids.isEmpty()) {
|
||||||
plugin.readUids(this);
|
plugin.readUids(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
book = new Book(bookFile);
|
book = new Book(bookFile);
|
||||||
} else {
|
} else {
|
||||||
book.readMetaInfo();
|
book.readMetainfo();
|
||||||
}
|
}
|
||||||
} catch (BookReadingException e) {
|
} catch (BookReadingException e) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -151,7 +151,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
fileInfos.save();
|
fileInfos.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
book.readMetaInfo();
|
book.readMetainfo();
|
||||||
// loaded from db
|
// loaded from db
|
||||||
addBook(book, false);
|
addBook(book, false);
|
||||||
return book;
|
return book;
|
||||||
|
@ -508,7 +508,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
}
|
}
|
||||||
if (!fileInfos.check(file, true)) {
|
if (!fileInfos.check(file, true)) {
|
||||||
try {
|
try {
|
||||||
book.readMetaInfo();
|
book.readMetainfo();
|
||||||
saveBook(book);
|
saveBook(book);
|
||||||
} catch (BookReadingException e) {
|
} catch (BookReadingException e) {
|
||||||
doAdd = false;
|
doAdd = false;
|
||||||
|
@ -611,7 +611,7 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
final Book book = orphanedBooksByFileId.get(fileId);
|
final Book book = orphanedBooksByFileId.get(fileId);
|
||||||
if (book != null) {
|
if (book != null) {
|
||||||
if (doReadMetaInfo) {
|
if (doReadMetaInfo) {
|
||||||
book.readMetaInfo();
|
book.readMetainfo();
|
||||||
}
|
}
|
||||||
newBooks.add(book);
|
newBooks.add(book);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public abstract class FormatPlugin {
|
||||||
public List<FileEncryptionInfo> readEncryptionInfos(Book book) {
|
public List<FileEncryptionInfo> readEncryptionInfos(Book book) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
public abstract void readMetaInfo(Book book) throws BookReadingException;
|
public abstract void readMetainfo(Book book) throws BookReadingException;
|
||||||
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;
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class NativeFormatPlugin extends FormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
synchronized public void readMetaInfo(Book book) throws BookReadingException {
|
synchronized public void readMetainfo(Book book) throws BookReadingException {
|
||||||
final int code = readMetaInfoNative(book);
|
final int code = readMetainfoNative(book);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
throw new BookReadingException(
|
throw new BookReadingException(
|
||||||
"nativeCodeFailure",
|
"nativeCodeFailure",
|
||||||
|
@ -62,7 +62,7 @@ public class NativeFormatPlugin extends FormatPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private native int readMetaInfoNative(Book book);
|
private native int readMetainfoNative(Book book);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FileEncryptionInfo> readEncryptionInfos(Book book) {
|
public List<FileEncryptionInfo> readEncryptionInfos(Book book) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class FB2MetaInfoReader extends ZLXMLReaderAdapter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readMetaInfo() throws BookReadingException {
|
public void readMetainfo() throws BookReadingException {
|
||||||
myReadState = READ_NOTHING;
|
myReadState = READ_NOTHING;
|
||||||
myAuthorNames[0] = "";
|
myAuthorNames[0] = "";
|
||||||
myAuthorNames[1] = "";
|
myAuthorNames[1] = "";
|
||||||
|
|
|
@ -43,8 +43,8 @@ public class FB2Plugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readMetaInfo(Book book) throws BookReadingException {
|
public void readMetainfo(Book book) throws BookReadingException {
|
||||||
new FB2MetaInfoReader(book).readMetaInfo();
|
new FB2MetaInfoReader(book).readMetainfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,7 @@ class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
||||||
myBook.setLanguage(null);
|
myBook.setLanguage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readMetaInfo(ZLFile file) throws BookReadingException {
|
void readMetainfo(ZLFile file) throws BookReadingException {
|
||||||
myReadState = ReadState.Nothing;
|
myReadState = ReadState.Nothing;
|
||||||
mySeriesTitle = "";
|
mySeriesTitle = "";
|
||||||
mySeriesIndex = null;
|
mySeriesIndex = null;
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class OEBPlugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readMetaInfo(Book book) throws BookReadingException {
|
public void readMetainfo(Book book) throws BookReadingException {
|
||||||
new OEBMetaInfoReader(book).readMetaInfo(getOpfFile(book.File));
|
new OEBMetaInfoReader(book).readMetainfo(getOpfFile(book.File));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class MobipocketPlugin extends JavaFormatPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readMetaInfo(Book book) throws BookReadingException {
|
public void readMetainfo(Book book) throws BookReadingException {
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
try {
|
try {
|
||||||
stream = book.File.getInputStream();
|
stream = book.File.getInputStream();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue