+ new getId() JNI method

This commit is contained in:
kelson42 2013-12-08 20:24:59 +01:00
parent 413e4c2ee1
commit 46104f74ba
6 changed files with 26 additions and 0 deletions

17
kiwix.c
View File

@ -81,6 +81,23 @@ JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getMainPage(JNIEnv
return url;
}
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getId(JNIEnv *env, jobject obj) {
jstring id;
pthread_mutex_lock(&readerLock);
if (reader != NULL) {
try {
std::string cId = reader->getId();
id = c2jni(cId, env);
} catch (exception &e) {
std::cerr << e.what() << std::endl;
}
}
pthread_mutex_unlock(&readerLock);
return id;
}
JNIEXPORT jboolean JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_loadZIM(JNIEnv *env, jobject obj, jstring path) {
jboolean retVal = JNI_TRUE;
std::string cPath = jni2c(path, env);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,7 @@
package org.kiwix.kiwixmobile;
public class JNIKiwix {
public native String getMainPage();
public native String getId();
public native boolean loadZIM(String path);
public native byte[] getContent(String url, JNIKiwixString mimeType, JNIKiwixInt size);
public native boolean searchSuggestions(String prefix, int count);

View File

@ -67,6 +67,14 @@ public class ZimContentProvider extends ContentProvider {
}
}
public static String getId() {
if (jniKiwix==null || zimFileName==null)
return null;
else {
return jniKiwix.getId();
}
}
public static boolean searchSuggestions(String prefix, int count) {
if (jniKiwix==null || zimFileName==null)
return false;