Implement getLanguage() to get the ZIM file language code

This commit is contained in:
Kelson42 2015-01-01 19:28:04 +01:00
parent 3e93bff32a
commit 105f730b11
6 changed files with 26 additions and 1 deletions

17
kiwix.c
View File

@ -99,6 +99,23 @@ JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getId(JNIEnv *env,
return id;
}
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getLanguage(JNIEnv *env, jobject obj) {
jstring language;
pthread_mutex_lock(&readerLock);
if (reader != NULL) {
try {
std::string cLanguage = reader->getLanguage();
language = c2jni(cLanguage, env);
} catch (exception &e) {
std::cerr << e.what() << std::endl;
}
}
pthread_mutex_unlock(&readerLock);
return language;
}
JNIEXPORT jstring JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getMimeType(JNIEnv *env, jobject obj, jstring url) {
jstring mimeType;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,6 +22,7 @@ package org.kiwix.kiwixmobile;
public class JNIKiwix {
public native String getMainPage();
public native String getId();
public native String getLanguage();
public native String getMimeType(String url);
public native boolean loadZIM(String path);
public native byte[] getContent(String url, JNIKiwixString mimeType, JNIKiwixInt size);
@ -30,7 +31,6 @@ 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 getLanguage(JNIKiwixString language);
public native boolean getDate(JNIKiwixString language);
public native boolean getFavicon(JNIKiwixString content, JNIKiwixString mimeType);
public native boolean getCreator(JNIKiwixString creator);

View File

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