mirror of https://github.com/kiwix/libkiwix.git
Fix JNI for android integration
This commit is contained in:
parent
7a59779b77
commit
d2f7503cfa
|
@ -5,10 +5,12 @@ set -e
|
|||
BUILD_PATH=$(pwd)
|
||||
|
||||
echo "javac -d $BUILD_PATH/src/android $@"
|
||||
javac -d $BUILD_PATH/src/android "$@"
|
||||
javac -d $BUILD_PATH/src/android/ "$@"
|
||||
|
||||
|
||||
cd $BUILD_PATH/src/android
|
||||
echo "javah -jni org.kiwix.kiwixlib.JNIKiwix"
|
||||
echo "javah -jni org.kiwix.kiwixlib"
|
||||
javah -jni org.kiwix.kiwixlib.JNIKiwix
|
||||
javah -jni org.kiwix.kiwixlib.JNIKiwixReader
|
||||
javah -jni org.kiwix.kiwixlib.JNIKiwixSearcher
|
||||
cd $BUILD_PATH
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
|
||||
#include <jni.h>
|
||||
#include <zim/file.h>
|
||||
#include "org_kiwix_kiwixlib_JNIKiwix.h"
|
||||
#include "org_kiwix_kiwixlib_JNIKiwixReader.h"
|
||||
|
||||
#include "common/base64.h"
|
||||
#include "reader.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* Kiwix Reader JNI functions */
|
||||
JNIEXPORT jlong JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_get_nativeReader(
|
||||
JNIEXPORT jlong JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getNativeReader(
|
||||
JNIEnv* env, jobject obj, jstring filename)
|
||||
{
|
||||
std::string cPath = jni2c(filename, env);
|
||||
|
@ -301,21 +301,18 @@ Java_org_kiwix_kiwixlib_JNIKiwixReader_getPageUrlFromTitle(JNIEnv* env,
|
|||
return retVal;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getTitle(
|
||||
JNIEnv* env, jobject obj, jobject titleObj)
|
||||
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixlib_JNIKiwixReader_getTitle(
|
||||
JNIEnv* env, jobject obj)
|
||||
{
|
||||
jboolean retVal = JNI_FALSE;
|
||||
std::string cTitle;
|
||||
jstring title;
|
||||
|
||||
try {
|
||||
std::string cTitle = READER->getTitle();
|
||||
setStringObjValue(cTitle, titleObj, env);
|
||||
retVal = JNI_TRUE;
|
||||
title = c2jni(cTitle, env);
|
||||
} catch (...) {
|
||||
std::cerr << "Unable to get ZIM title" << std::endl;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
return title;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
|
||||
#include <zim/file.h>
|
||||
#include "org_kiwix_kiwixlib_JNIKiwixSearcher.h"
|
||||
|
||||
#include "reader.h"
|
||||
#include "searcher.h"
|
||||
|
|
|
@ -8,7 +8,9 @@ kiwix_jni = custom_target('jni',
|
|||
'org/kiwix/kiwixlib/JNIKiwixInt.java',
|
||||
'org/kiwix/kiwixlib/JNIKiwixString.java',
|
||||
'org/kiwix/kiwixlib/JNIKiwixBool.java'],
|
||||
output: ['org_kiwix_kiwixlib_JNIKiwix.h'],
|
||||
output: ['org_kiwix_kiwixlib_JNIKiwix.h',
|
||||
'org_kiwix_kiwixlib_JNIKiwixReader.h',
|
||||
'org_kiwix_kiwixlib_JNIKiwixSearcher.h'],
|
||||
command:[jni_generator, '@INPUT@']
|
||||
)
|
||||
|
||||
|
|
|
@ -77,11 +77,13 @@ public class JNIKiwixReader
|
|||
|
||||
public JNIKiwixReader(String filename)
|
||||
{
|
||||
nativeHandle = get_nativeReader(filename);
|
||||
nativeHandle = getNativeReader(filename);
|
||||
}
|
||||
public JNIKiwixReader() {
|
||||
|
||||
}
|
||||
public native void dispose();
|
||||
|
||||
private native long get_nativeReader(String filename);
|
||||
private native long getNativeReader(String filename);
|
||||
private long nativeHandle;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class JNIKiwixSearcher
|
|||
usedReaders.addElement(reader);
|
||||
};
|
||||
|
||||
public native Result search(String query, int count);
|
||||
public native void search(String query, int count);
|
||||
|
||||
public native Result get_next_result();
|
||||
public native boolean has_more_result();
|
||||
|
|
Loading…
Reference in New Issue