-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbook.cpp
More file actions
102 lines (74 loc) · 2.42 KB
/
book.cpp
File metadata and controls
102 lines (74 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* 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
#define TYPENAME libkiwix_Book
#include <macros.h>
METHOD0(jobject, getNativeBook)
{
return NEW_RESOURCE(std::make_shared<NATIVE_TYPE>());
}
METHOD(void, update__Lorg_kiwix_libkiwix_Book_2, jobject otherBook)
{
THIS->update(*getPtr<kiwix::Book>(env, otherBook));
}
METHOD(void, update__Lorg_kiwix_libzim_Archive_2, jobject archive)
{
THIS->update(*getPtr<zim::Archive>(env, archive));
}
GETTER(jstring, getId)
GETTER(jstring, getPath)
GETTER(jstring, getHumanReadableIdFromPath)
GETTER(jboolean, isPathValid)
GETTER(jstring, getTitle)
GETTER(jstring, getDescription)
GETTER(jstring, getLanguage)
GETTER(jstring, getCreator)
GETTER(jstring, getPublisher)
GETTER(jstring, getDate)
GETTER(jstring, getUrl)
GETTER(jstring, getName)
GETTER(jstring, getFlavour)
GETTER(jstring, getCategory)
GETTER(jstring, getTags)
METHOD(jstring, getTagStr, jstring tagName) try {
return TO_JNI(THIS->getTagStr(TO_C(tagName)));
} catch(...) {
return c2jni<std::string>("", env);
}
GETTER(jlong, getArticleCount)
GETTER(jlong, getMediaCount)
GETTER(jlong, getSize)
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(illu);
env->SetObjectArrayElement(retArray, index++, wrapper);
}
return retArray;
}
METHOD(jobject, getIllustration, jint size) {
return BUILD_WRAPPER(THIS->getIllustration(TO_C(size)));
}