+ JNI getRandomPage()

This commit is contained in:
kelson42 2013-04-05 23:35:56 +02:00
parent ee19d5b834
commit bccd1d1806
6 changed files with 25 additions and 3 deletions

View File

@ -13,11 +13,11 @@ import shutil
from subprocess import call, check_output
# switchs for debugging purposes ; please ignore.
CREATE_TOOLCHAIN = True
COMPILE_LIBLZMA = True
CREATE_TOOLCHAIN = False
COMPILE_LIBLZMA = False
COMPILE_LIBZIM = True
COMPILE_LIBKIWIX = True
STRIP_LIBKIWIX = True
STRIP_LIBKIWIX = False
COMPILE_APK = True
# store the OS's environment PATH as we'll mess with it

21
kiwix.c
View File

@ -236,3 +236,24 @@ JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwibx_getDescription
return retVal;
}
JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwibx_getRandomPage
(JNIEnv *env, jobject obj, jobject urlObj) {
jboolean retVal = JNI_FALSE;
std::string cUrl;
pthread_mutex_lock(&readerLock);
try {
if (reader != NULL) {
std::string cUrl = reader->getRandomPageUrl();
setStringObjValue(cUrl, urlObj, env);
retVal = JNI_TRUE;
}
} catch (exception &e) {
std::cerr << e.what() << std::endl;
}
pthread_mutex_unlock(&readerLock);
return retVal;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,7 @@ public class JNIKiwix {
public native boolean getPageUrlFromTitle(String title, JNIKiwixString url);
public native boolean getTitle(JNIKiwixString title);
public native boolean getDescription(JNIKiwixString title);
public native boolean getRandomPage(JNIKiwixString url);
static {
System.loadLibrary("kiwix");