Skip to content

Commit a63ab3a

Browse files
committed
disable odrcor wvware; bump odrcore version
1 parent 6192349 commit a63ab3a

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

app/conanfile.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[requires]
2-
odrcore/5.0.0-pre11
2+
odrcore/5.0.0-pre12
33

44
[generators]
55
CMakeToolchain
66
CMakeDeps
7+
8+
[options]
9+
odrcore/*:shared=True
10+
odrcore/*:with_pdf2htmlEX=True
11+
odrcore/*:with_wvWare=False

app/src/main/cpp/CoreWrapper.cpp

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,24 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
126126

127127
__android_log_print(ANDROID_LOG_VERBOSE, "smn", "Open %s", inputPathCpp.c_str());
128128

129-
const auto file = odr::open(inputPathCpp);
129+
auto file = odr::open(inputPathCpp);
130130

131-
if (file.is_document_file()) {
132-
odr::DocumentFile document_file = file.document_file();
133-
if (document_file.password_encrypted()) {
134-
if (!passwordCpp.has_value() || !document_file.decrypt(passwordCpp.value())) {
135-
env->SetIntField(result, errorField, -2);
136-
return result;
137-
}
131+
if (file.password_encrypted()) {
132+
if (!passwordCpp.has_value()) {
133+
env->SetIntField(result, errorField, -2);
134+
return result;
138135
}
136+
try {
137+
file = file.decrypt(passwordCpp.value());
138+
} catch (...) {
139+
env->SetIntField(result, errorField, -2);
140+
return result;
141+
}
142+
}
143+
144+
if (file.is_document_file()) {
139145
// TODO this will cause a second load
140-
s_document = document_file.document();
146+
s_document = file.document_file().document();
141147
}
142148

143149
extensionCpp = odr::type_to_string(file.file_type());
@@ -317,16 +323,22 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFile(JNIEnv *env, jclass cla
317323
odr::DecoderEngine::odr};
318324
odr::DecodedFile file = odr::open(inputPathCpp, decodePreference);
319325

320-
if (file.is_document_file()) {
321-
odr::DocumentFile document_file = file.document_file();
322-
if (document_file.password_encrypted()) {
323-
if (!passwordCpp.has_value() || !document_file.decrypt(passwordCpp.value())) {
324-
env->SetIntField(result, errorField, -2);
325-
return result;
326-
}
326+
if (file.password_encrypted()) {
327+
if (!passwordCpp.has_value()) {
328+
env->SetIntField(result, errorField, -2);
329+
return result;
330+
}
331+
try {
332+
file = file.decrypt(passwordCpp.value());
333+
} catch (...) {
334+
env->SetIntField(result, errorField, -2);
335+
return result;
327336
}
337+
}
338+
339+
if (file.is_document_file()) {
328340
// TODO this will cause a second load
329-
s_document = document_file.document();
341+
s_document = file.document_file().document();
330342
}
331343

332344
odr::HtmlConfig htmlConfig;

0 commit comments

Comments
 (0)