OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <AdblockPlus.h> | 18 #include <AdblockPlus.h> |
| 19 #include <AdblockPlus/DefaultFileSystem.h> |
19 #include "Utils.h" | 20 #include "Utils.h" |
20 #include "JniCallbacks.h" | 21 #include "JniCallbacks.h" |
21 #include "JniJsEngine.h" | 22 #include "JniJsEngine.h" |
22 | 23 |
23 static void TransformAppInfo(JNIEnv* env, jobject jAppInfo, AdblockPlus::AppInfo
& appInfo) | 24 static void TransformAppInfo(JNIEnv* env, jobject jAppInfo, AdblockPlus::AppInfo
& appInfo) |
24 { | 25 { |
25 jclass clazz = env->GetObjectClass(jAppInfo); | 26 jclass clazz = env->GetObjectClass(jAppInfo); |
26 | 27 |
27 appInfo.application = JniGetStringField(env, clazz, jAppInfo, "application"); | 28 appInfo.application = JniGetStringField(env, clazz, jAppInfo, "application"); |
28 appInfo.applicationVersion = JniGetStringField(env, clazz, jAppInfo, "applicat
ionVersion"); | 29 appInfo.applicationVersion = JniGetStringField(env, clazz, jAppInfo, "applicat
ionVersion"); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 133 } |
133 CATCH_AND_THROW(env) | 134 CATCH_AND_THROW(env) |
134 } | 135 } |
135 | 136 |
136 static void JNICALL JniSetDefaultFileSystem(JNIEnv* env, jclass clazz, jlong ptr
, jstring jBasePath) | 137 static void JNICALL JniSetDefaultFileSystem(JNIEnv* env, jclass clazz, jlong ptr
, jstring jBasePath) |
137 { | 138 { |
138 AdblockPlus::JsEnginePtr& engine = GetJsEnginePtrRef(ptr); | 139 AdblockPlus::JsEnginePtr& engine = GetJsEnginePtrRef(ptr); |
139 | 140 |
140 try | 141 try |
141 { | 142 { |
142 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); | 143 auto fileSystem = std::make_shared<AdblockPlus::DefaultFileSystemSync>(); |
143 | 144 |
144 std::string basePath = JniJavaToStdString(env, jBasePath); | 145 std::string basePath = JniJavaToStdString(env, jBasePath); |
145 reinterpret_cast<AdblockPlus::DefaultFileSystem*>(fileSystem.get())->SetBase
Path(basePath); | 146 fileSystem->SetBasePath(basePath); |
146 | 147 |
147 engine->SetFileSystem(fileSystem); | 148 engine->SetFileSystem(fileSystem); |
148 } | 149 } |
149 CATCH_AND_THROW(env) | 150 CATCH_AND_THROW(env) |
150 } | 151 } |
151 | 152 |
152 static void JNICALL JniSetDefaultLogSystem(JNIEnv* env, jclass clazz, jlong ptr) | 153 static void JNICALL JniSetDefaultLogSystem(JNIEnv* env, jclass clazz, jlong ptr) |
153 { | 154 { |
154 AdblockPlus::JsEnginePtr& engine = GetJsEnginePtrRef(ptr); | 155 AdblockPlus::JsEnginePtr& engine = GetJsEnginePtrRef(ptr); |
155 | 156 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 247 |
247 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, | 248 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, |
248 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
, | 249 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue }
, |
249 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
NewStringValue } | 250 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni
NewStringValue } |
250 }; | 251 }; |
251 | 252 |
252 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
egisterNatives(JNIEnv *env, jclass clazz) | 253 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r
egisterNatives(JNIEnv *env, jclass clazz) |
253 { | 254 { |
254 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 255 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
255 } | 256 } |
OLD | NEW |