mirror of
https://github.com/kiwix/java-libkiwix.git
synced 2025-09-10 23:59:10 -04:00
Use Illustration api instead of deprecated favicon for Book
This commit is contained in:
parent
876d38b9f3
commit
9426c6fcb8
@ -52,6 +52,7 @@ add_library(
|
|||||||
libkiwix/kiwixserver.cpp
|
libkiwix/kiwixserver.cpp
|
||||||
libkiwix/library.cpp
|
libkiwix/library.cpp
|
||||||
libkiwix/manager.cpp
|
libkiwix/manager.cpp
|
||||||
|
libkiwix/illustration.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(libkiwix
|
find_library(libkiwix
|
||||||
|
@ -66,10 +66,21 @@ GETTER(jstring, getTags)
|
|||||||
GETTER(jlong, getArticleCount)
|
GETTER(jlong, getArticleCount)
|
||||||
GETTER(jlong, getMediaCount)
|
GETTER(jlong, getMediaCount)
|
||||||
GETTER(jlong, getSize)
|
GETTER(jlong, getSize)
|
||||||
GETTER(jstring, getFavicon)
|
|
||||||
GETTER(jstring, getFaviconUrl)
|
|
||||||
GETTER(jstring, getFaviconMimeType)
|
|
||||||
|
|
||||||
|
METHOD0(jobjectArray, getIllustrations) {
|
||||||
|
auto illustrations = THIS->getIllustrations();
|
||||||
|
jobjectArray retArray = createArray(env, illustrations.size(), "org/kiwix/libkiwix/Illustration");
|
||||||
|
size_t index = 0;
|
||||||
|
for (auto illu: illustrations) {
|
||||||
|
auto wrapper = BUILD_WRAPPER("org/kiwix/libkiwx/Illustration", illu);
|
||||||
|
env->SetObjectArrayElement(retArray, index++, wrapper);
|
||||||
|
}
|
||||||
|
return retArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD(jobject, getIllustration, jint size) {
|
||||||
|
return BUILD_WRAPPER("org/kiwix/libkiwix/Illustration", THIS->getIllustration(TO_C(size)));
|
||||||
|
}
|
||||||
METHOD(jstring, getTagStr, jstring tagName) try {
|
METHOD(jstring, getTagStr, jstring tagName) try {
|
||||||
return TO_JNI(THIS->getTagStr(TO_C(tagName)));
|
return TO_JNI(THIS->getTagStr(TO_C(tagName)));
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
53
lib/src/main/cpp/libkiwix/illustration.cpp
Normal file
53
lib/src/main/cpp/libkiwix/illustration.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Matthieu Gautier <mgautier@kymeria.fr>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <jni.h>
|
||||||
|
#include "org_kiwix_libkiwix_Book.h"
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
#include "book.h"
|
||||||
|
#include <zim/archive.h>
|
||||||
|
|
||||||
|
#define NATIVE_TYPE kiwix::Book::Illustration
|
||||||
|
#define TYPENAME libkiwix_Illustration
|
||||||
|
#include <macros.h>
|
||||||
|
|
||||||
|
METHOD0(void, dispose)
|
||||||
|
{
|
||||||
|
dispose<NATIVE_TYPE>(env, thisObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD0(jint, width) {
|
||||||
|
return TO_JNI(THIS->width);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD0(jint, height) {
|
||||||
|
return TO_JNI(THIS->width);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD0(jstring, mimeType) {
|
||||||
|
return TO_JNI(THIS->mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
METHOD0(jstring, url) {
|
||||||
|
return TO_JNI(THIS->url);
|
||||||
|
}
|
||||||
|
|
||||||
|
GETTER(jstring, getData)
|
@ -147,8 +147,10 @@ template<typename T>
|
|||||||
struct JType { };
|
struct JType { };
|
||||||
|
|
||||||
template<> struct JType<bool>{ typedef jboolean type_t; };
|
template<> struct JType<bool>{ typedef jboolean type_t; };
|
||||||
|
template<> struct JType<int16_t>{ typedef jint type_t; };
|
||||||
template<> struct JType<int32_t>{ typedef jint type_t; };
|
template<> struct JType<int32_t>{ typedef jint type_t; };
|
||||||
template<> struct JType<int64_t>{ typedef jlong type_t; };
|
template<> struct JType<int64_t>{ typedef jlong type_t; };
|
||||||
|
template<> struct JType<uint16_t>{ typedef jint type_t; };
|
||||||
template<> struct JType<uint64_t> { typedef jlong type_t; };
|
template<> struct JType<uint64_t> { typedef jlong type_t; };
|
||||||
template<> struct JType<uint32_t> { typedef jlong type_t; };
|
template<> struct JType<uint32_t> { typedef jlong type_t; };
|
||||||
template<> struct JType<std::string>{ typedef jstring type_t; };
|
template<> struct JType<std::string>{ typedef jstring type_t; };
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package org.kiwix.libkiwix;
|
package org.kiwix.libkiwix;
|
||||||
|
|
||||||
import org.kiwix.libzim.Archive;
|
import org.kiwix.libzim.Archive;
|
||||||
|
import org.kiwix.libkiwix.Illustration;
|
||||||
|
|
||||||
public class Book
|
public class Book
|
||||||
{
|
{
|
||||||
@ -40,9 +41,8 @@ public class Book
|
|||||||
public native long getMediaCount();
|
public native long getMediaCount();
|
||||||
public native long getSize();
|
public native long getSize();
|
||||||
|
|
||||||
public native String getFavicon();
|
public native Illustration[] getIllustrations();
|
||||||
public native String getFaviconUrl();
|
public native Illustration getIllustration(int size);
|
||||||
public native String getFaviconMimeType();
|
|
||||||
|
|
||||||
private native void allocate();
|
private native void allocate();
|
||||||
private native void dispose();
|
private native void dispose();
|
||||||
|
17
lib/src/main/java/org/kiwix/libkiwix/Illustration.java
Normal file
17
lib/src/main/java/org/kiwix/libkiwix/Illustration.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
package org.kiwix.libkiwix;
|
||||||
|
|
||||||
|
public class Illustration
|
||||||
|
{
|
||||||
|
public native int width();
|
||||||
|
public native int height();
|
||||||
|
public native String mimeType();
|
||||||
|
public native String url();
|
||||||
|
|
||||||
|
public native String getData();
|
||||||
|
@Override
|
||||||
|
protected void finalize() { dispose(); }
|
||||||
|
|
||||||
|
private native void dispose();
|
||||||
|
private long nativeHandle;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user