mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
book uids (in progress)
This commit is contained in:
parent
20491d9a12
commit
9eb54b261a
30 changed files with 205 additions and 16 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "fbreader/src/library/Author.h"
|
||||
#include "fbreader/src/library/Book.h"
|
||||
#include "fbreader/src/library/Tag.h"
|
||||
#include "fbreader/src/library/UID.h"
|
||||
|
||||
static shared_ptr<FormatPlugin> findCppPlugin(jobject base) {
|
||||
const std::string fileType = AndroidUtil::Method_NativeFormatPlugin_supportedFileType->callForCppString(base);
|
||||
|
@ -37,6 +38,17 @@ static shared_ptr<FormatPlugin> findCppPlugin(jobject base) {
|
|||
return plugin;
|
||||
}
|
||||
|
||||
static void fillUids(JNIEnv* env, jobject javaBook, Book &book) {
|
||||
const UIDList &uids = book.uids();
|
||||
for (UIDList::const_iterator it = uids.begin(); it != uids.end(); ++it) {
|
||||
jstring type = AndroidUtil::createJavaString(env, (*it)->Type);
|
||||
jstring id = AndroidUtil::createJavaString(env, (*it)->Id);
|
||||
AndroidUtil::Method_Book_addUid->call(javaBook, type, id);
|
||||
env->DeleteLocalRef(id);
|
||||
env->DeleteLocalRef(type);
|
||||
}
|
||||
}
|
||||
|
||||
static void fillMetaInfo(JNIEnv* env, jobject javaBook, Book &book) {
|
||||
jstring javaString;
|
||||
|
||||
|
@ -81,6 +93,8 @@ static void fillMetaInfo(JNIEnv* env, jobject javaBook, Book &book) {
|
|||
const Tag &tag = *tags[i];
|
||||
AndroidUtil::Method_Book_addTag->call(javaBook, tag.javaTag(env));
|
||||
}
|
||||
|
||||
fillUids(env, javaBook, book);
|
||||
}
|
||||
|
||||
static void fillLanguageAndEncoding(JNIEnv* env, jobject javaBook, Book &book) {
|
||||
|
@ -116,6 +130,19 @@ JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPl
|
|||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readUidsNative(JNIEnv* env, jobject thiz, jobject javaBook) {
|
||||
shared_ptr<FormatPlugin> plugin = findCppPlugin(thiz);
|
||||
if (plugin.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<Book> book = Book::loadFromJavaBook(env, javaBook);
|
||||
|
||||
plugin->readUids(*book);
|
||||
fillUids(env, javaBook, *book);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_detectLanguageAndEncodingNative(JNIEnv* env, jobject thiz, jobject javaBook) {
|
||||
shared_ptr<FormatPlugin> plugin = findCppPlugin(thiz);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue