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 "Utils.h" | 19 #include "Utils.h" |
20 #include "JniCallbacks.h" | 20 #include "JniCallbacks.h" |
21 | 21 |
22 static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Su
bscriptionPtr>& subscriptions) | 22 static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Su
bscription>&& subscriptions) |
23 { | 23 { |
24 jobject list = NewJniArrayList(env); | 24 jobject list = NewJniArrayList(env); |
25 | 25 |
26 for (std::vector<AdblockPlus::SubscriptionPtr>::iterator it = subscriptions.be
gin(), end = subscriptions.end(); it != end; it++) | 26 for (std::vector<AdblockPlus::Subscription>::iterator it = subscriptions.begin
(), end = subscriptions.end(); it != end; it++) |
27 { | 27 { |
28 JniAddObjectToList(env, list, NewJniSubscription(env, *it)); | 28 JniAddObjectToList(env, list, NewJniSubscription(env, std::move(*it))); |
29 } | 29 } |
30 | 30 |
31 return list; | 31 return list; |
32 } | 32 } |
33 | 33 |
34 static AdblockPlus::FilterEngine::ContentType ConvertContentType(JNIEnv *env, | 34 static AdblockPlus::FilterEngine::ContentType ConvertContentType(JNIEnv *env, |
35 jobject jContentType) | 35 jobject jContentType) |
36 { | 36 { |
37 JniLocalReference<jclass> contentTypeClass(env, | 37 JniLocalReference<jclass> contentTypeClass(env, |
38 env->GetObjectClass(jContentType)); | 38 env->GetObjectClass(jContentType)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 CATCH_THROW_AND_RETURN(env, JNI_FALSE); | 91 CATCH_THROW_AND_RETURN(env, JNI_FALSE); |
92 } | 92 } |
93 | 93 |
94 static jobject JNICALL JniGetFilter(JNIEnv* env, jclass clazz, jlong ptr, jstrin
g jText) | 94 static jobject JNICALL JniGetFilter(JNIEnv* env, jclass clazz, jlong ptr, jstrin
g jText) |
95 { | 95 { |
96 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 96 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
97 std::string text = JniJavaToStdString(env, jText); | 97 std::string text = JniJavaToStdString(env, jText); |
98 | 98 |
99 try | 99 try |
100 { | 100 { |
101 AdblockPlus::FilterPtr filter = engine->GetFilter(text); | 101 return NewJniFilter(env, engine->GetFilter(text)); |
102 | |
103 return NewJniFilter(env, filter); | |
104 } | 102 } |
105 CATCH_THROW_AND_RETURN(env, 0); | 103 CATCH_THROW_AND_RETURN(env, 0); |
106 } | 104 } |
107 | 105 |
108 static jobject JNICALL JniGetListedFilters(JNIEnv* env, jclass clazz, jlong ptr) | 106 static jobject JNICALL JniGetListedFilters(JNIEnv* env, jclass clazz, jlong ptr) |
109 { | 107 { |
110 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 108 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
111 | 109 |
112 try | 110 try |
113 { | 111 { |
114 std::vector<AdblockPlus::FilterPtr> filters = engine->GetListedFilters(); | 112 std::vector<AdblockPlus::Filter> filters = engine->GetListedFilters(); |
115 | 113 |
116 jobject list = NewJniArrayList(env); | 114 jobject list = NewJniArrayList(env); |
117 | 115 |
118 for (std::vector<AdblockPlus::FilterPtr>::iterator it = filters.begin(), end
= filters.end(); it != end; it++) | 116 for (std::vector<AdblockPlus::Filter>::iterator it = filters.begin(), end =
filters.end(); it != end; it++) |
119 { | 117 { |
120 JniAddObjectToList(env, list, *JniLocalReference<jobject>(env, NewJniFilte
r(env, *it))); | 118 JniAddObjectToList(env, list, *JniLocalReference<jobject>(env, NewJniFilte
r(env, std::move(*it)))); |
121 } | 119 } |
122 | 120 |
123 return list; | 121 return list; |
124 } | 122 } |
125 CATCH_THROW_AND_RETURN(env, 0); | 123 CATCH_THROW_AND_RETURN(env, 0); |
126 } | 124 } |
127 | 125 |
128 static jobject JNICALL JniGetSubscription(JNIEnv* env, jclass clazz, jlong ptr,
jstring jUrl) | 126 static jobject JNICALL JniGetSubscription(JNIEnv* env, jclass clazz, jlong ptr,
jstring jUrl) |
129 { | 127 { |
130 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 128 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
131 std::string url = JniJavaToStdString(env, jUrl); | 129 std::string url = JniJavaToStdString(env, jUrl); |
132 | 130 |
133 try | 131 try |
134 { | 132 { |
135 AdblockPlus::SubscriptionPtr subscription = engine->GetSubscription(url); | 133 return NewJniSubscription(env, engine->GetSubscription(url)); |
136 | |
137 return NewJniSubscription(env, subscription); | |
138 } | 134 } |
139 CATCH_THROW_AND_RETURN(env, 0); | 135 CATCH_THROW_AND_RETURN(env, 0); |
140 } | 136 } |
141 | 137 |
142 static void JNICALL JniShowNextNotification(JNIEnv* env, jclass clazz, jlong ptr
, jstring jUrl) | 138 static void JNICALL JniShowNextNotification(JNIEnv* env, jclass clazz, jlong ptr
, jstring jUrl) |
143 { | 139 { |
144 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 140 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
145 std::string url = JniJavaToStdString(env, jUrl); | 141 std::string url = JniJavaToStdString(env, jUrl); |
146 | 142 |
147 try | 143 try |
148 { | 144 { |
149 engine->ShowNextNotification(url); | 145 engine->ShowNextNotification(url); |
150 } | 146 } |
151 CATCH_AND_THROW(env); | 147 CATCH_AND_THROW(env); |
152 } | 148 } |
153 | 149 |
154 static void JNICALL JniSetShowNotificationCallback(JNIEnv* env, jclass clazz, | 150 static void JNICALL JniSetShowNotificationCallback(JNIEnv* env, jclass clazz, |
155 jlong ptr, jlong callbackPtr) | 151 jlong ptr, jlong callbackPtr) |
156 { | 152 { |
157 AdblockPlus::FilterEnginePtr& engine = | 153 AdblockPlus::FilterEnginePtr& engine = |
158 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); | 154 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); |
| 155 |
159 JniShowNotificationCallback* const callback = | 156 JniShowNotificationCallback* const callback = |
160 JniLongToTypePtr<JniShowNotificationCallback>(callbackPtr); | 157 JniLongToTypePtr<JniShowNotificationCallback>(callbackPtr); |
161 AdblockPlus::FilterEngine::ShowNotificationCallback showNotificationCallback = | 158 |
162 std::bind(&JniShowNotificationCallback::Callback, callback, | 159 auto showNotificationCallback = [callback](AdblockPlus::Notification&& notific
ation) |
163 std::placeholders::_1); | 160 { |
| 161 callback->Callback(std::move(notification)); |
| 162 }; |
| 163 |
164 try | 164 try |
165 { | 165 { |
166 engine->SetShowNotificationCallback(showNotificationCallback); | 166 engine->SetShowNotificationCallback(showNotificationCallback); |
167 } | 167 } |
168 CATCH_AND_THROW(env) | 168 CATCH_AND_THROW(env) |
169 } | 169 } |
170 | 170 |
171 static void JNICALL JniRemoveShowNotificationCallback(JNIEnv* env, jclass clazz,
jlong ptr) | 171 static void JNICALL JniRemoveShowNotificationCallback(JNIEnv* env, jclass clazz,
jlong ptr) |
172 { | 172 { |
173 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 173 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
174 | 174 |
175 try | 175 try |
176 { | 176 { |
177 engine->RemoveShowNotificationCallback(); | 177 engine->RemoveShowNotificationCallback(); |
178 } | 178 } |
179 CATCH_AND_THROW(env); | 179 CATCH_AND_THROW(env); |
180 } | 180 } |
181 | 181 |
182 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon
g ptr) | 182 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon
g ptr) |
183 { | 183 { |
184 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 184 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
185 | 185 |
186 try | 186 try |
187 { | 187 { |
188 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS
ubscriptions(); | 188 return SubscriptionsToArrayList(env, engine->GetListedSubscriptions()); |
189 | |
190 return SubscriptionsToArrayList(env, subscriptions); | |
191 } | 189 } |
192 CATCH_THROW_AND_RETURN(env, 0); | 190 CATCH_THROW_AND_RETURN(env, 0); |
193 } | 191 } |
194 | 192 |
195 static jobject JNICALL JniFetchAvailableSubscriptions(JNIEnv* env, jclass clazz,
jlong ptr) | 193 static jobject JNICALL JniFetchAvailableSubscriptions(JNIEnv* env, jclass clazz,
jlong ptr) |
196 { | 194 { |
197 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 195 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
198 | 196 |
199 try | 197 try |
200 { | 198 { |
201 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->FetchAvail
ableSubscriptions(); | 199 return SubscriptionsToArrayList(env, engine->FetchAvailableSubscriptions()); |
202 | |
203 return SubscriptionsToArrayList(env, subscriptions); | |
204 } | 200 } |
205 CATCH_THROW_AND_RETURN(env, 0); | 201 CATCH_THROW_AND_RETURN(env, 0); |
206 } | 202 } |
207 | 203 |
208 static void JNICALL JniRemoveUpdateAvailableCallback(JNIEnv* env, jclass clazz, | 204 static void JNICALL JniRemoveUpdateAvailableCallback(JNIEnv* env, jclass clazz, |
209 jlong ptr) | 205 jlong ptr) |
210 { | 206 { |
211 AdblockPlus::FilterEnginePtr& engine = | 207 AdblockPlus::FilterEnginePtr& engine = |
212 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); | 208 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); |
213 try | 209 try |
214 { | 210 { |
215 engine->RemoveUpdateAvailableCallback(); | 211 engine->RemoveUpdateAvailableCallback(); |
216 } | 212 } |
217 CATCH_AND_THROW(env) | 213 CATCH_AND_THROW(env) |
218 } | 214 } |
219 | 215 |
220 static void JNICALL JniSetUpdateAvailableCallback(JNIEnv* env, jclass clazz, | 216 static void JNICALL JniSetUpdateAvailableCallback(JNIEnv* env, jclass clazz, |
221 jlong ptr, jlong callbackPtr) | 217 jlong ptr, jlong callbackPtr) |
222 { | 218 { |
223 AdblockPlus::FilterEnginePtr& engine = | 219 AdblockPlus::FilterEnginePtr& engine = |
224 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); | 220 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); |
225 JniUpdateAvailableCallback* const callback = | 221 JniUpdateAvailableCallback* const callback = |
226 JniLongToTypePtr<JniUpdateAvailableCallback>(callbackPtr); | 222 JniLongToTypePtr<JniUpdateAvailableCallback>(callbackPtr); |
227 AdblockPlus::FilterEngine::UpdateAvailableCallback updateAvailableCallback = | 223 |
| 224 const AdblockPlus::FilterEngine::UpdateAvailableCallback updateAvailableCallba
ck = |
228 std::bind(&JniUpdateAvailableCallback::Callback, callback, | 225 std::bind(&JniUpdateAvailableCallback::Callback, callback, |
229 std::placeholders::_1); | 226 std::placeholders::_1); |
230 try | 227 try |
231 { | 228 { |
232 engine->SetUpdateAvailableCallback(updateAvailableCallback); | 229 engine->SetUpdateAvailableCallback(updateAvailableCallback); |
233 } | 230 } |
234 CATCH_AND_THROW(env) | 231 CATCH_AND_THROW(env) |
235 } | 232 } |
236 | 233 |
237 static void JNICALL JniRemoveFilterChangeCallback(JNIEnv* env, jclass clazz, jlo
ng ptr) | 234 static void JNICALL JniRemoveFilterChangeCallback(JNIEnv* env, jclass clazz, jlo
ng ptr) |
238 { | 235 { |
239 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 236 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
240 | 237 |
241 try | 238 try |
242 { | 239 { |
243 engine->RemoveFilterChangeCallback(); | 240 engine->RemoveFilterChangeCallback(); |
244 } | 241 } |
245 CATCH_AND_THROW(env) | 242 CATCH_AND_THROW(env) |
246 } | 243 } |
247 | 244 |
248 static void JNICALL JniSetFilterChangeCallback(JNIEnv* env, jclass clazz, | 245 static void JNICALL JniSetFilterChangeCallback(JNIEnv* env, jclass clazz, |
249 jlong ptr, jlong filterPtr) | 246 jlong ptr, jlong filterPtr) |
250 { | 247 { |
251 AdblockPlus::FilterEnginePtr& engine = | 248 AdblockPlus::FilterEnginePtr& engine = |
252 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); | 249 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); |
253 JniFilterChangeCallback* callback = JniLongToTypePtr<JniFilterChangeCallback>( | 250 JniFilterChangeCallback* callback = JniLongToTypePtr<JniFilterChangeCallback>( |
254 filterPtr); | 251 filterPtr); |
255 | 252 |
256 AdblockPlus::FilterEngine::FilterChangeCallback filterCallback = | 253 auto filterCallback = [callback](const std::string& arg, AdblockPlus::JsValue&
& jsValue) |
257 std::bind(&JniFilterChangeCallback::Callback, callback, | 254 { |
258 std::placeholders::_1, std::placeholders::_2); | 255 callback->Callback(arg, std::move(jsValue)); |
| 256 }; |
259 | 257 |
260 try | 258 try |
261 { | 259 { |
262 engine->SetFilterChangeCallback(filterCallback); | 260 engine->SetFilterChangeCallback(filterCallback); |
263 } | 261 } |
264 CATCH_AND_THROW(env) | 262 CATCH_AND_THROW(env) |
265 } | 263 } |
266 | 264 |
267 static void JNICALL JniForceUpdateCheck(JNIEnv* env, jclass clazz, jlong ptr, jl
ong updaterPtr) | 265 static void JNICALL JniForceUpdateCheck(JNIEnv* env, jclass clazz, jlong ptr, jl
ong updaterPtr) |
268 { | 266 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 { | 316 { |
319 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 317 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
320 | 318 |
321 std::string url = JniJavaToStdString(env, jUrl); | 319 std::string url = JniJavaToStdString(env, jUrl); |
322 AdblockPlus::FilterEngine::ContentType contentType = | 320 AdblockPlus::FilterEngine::ContentType contentType = |
323 ConvertContentType(env, jContentType); | 321 ConvertContentType(env, jContentType); |
324 std::string documentUrl = JniJavaToStdString(env, jDocumentUrl); | 322 std::string documentUrl = JniJavaToStdString(env, jDocumentUrl); |
325 | 323 |
326 try | 324 try |
327 { | 325 { |
328 AdblockPlus::FilterPtr filter = engine->Matches(url, contentType, documentUr
l); | 326 AdblockPlus::FilterPtr filterPtr = engine->Matches(url, contentType, documen
tUrl); |
329 | 327 |
330 return NewJniFilter(env, filter); | 328 return filterPtr.get() ? NewJniFilter(env, std::move(*filterPtr)) : 0; |
331 } | 329 } |
332 CATCH_THROW_AND_RETURN(env, 0) | 330 CATCH_THROW_AND_RETURN(env, 0) |
333 } | 331 } |
334 | 332 |
335 static void JavaStringArrayToStringVector(JNIEnv* env, jobjectArray jArray, | 333 static void JavaStringArrayToStringVector(JNIEnv* env, jobjectArray jArray, |
336 std::vector<std::string>& out) | 334 std::vector<std::string>& out) |
337 { | 335 { |
338 if (jArray) | 336 if (jArray) |
339 { | 337 { |
340 jsize len = env->GetArrayLength(jArray); | 338 jsize len = env->GetArrayLength(jArray); |
(...skipping 17 matching lines...) Expand all Loading... |
358 | 356 |
359 std::string url = JniJavaToStdString(env, jUrl); | 357 std::string url = JniJavaToStdString(env, jUrl); |
360 AdblockPlus::FilterEngine::ContentType contentType = | 358 AdblockPlus::FilterEngine::ContentType contentType = |
361 ConvertContentType(env, jContentType); | 359 ConvertContentType(env, jContentType); |
362 | 360 |
363 std::vector<std::string> documentUrls; | 361 std::vector<std::string> documentUrls; |
364 JavaStringArrayToStringVector(env, jDocumentUrls, documentUrls); | 362 JavaStringArrayToStringVector(env, jDocumentUrls, documentUrls); |
365 | 363 |
366 try | 364 try |
367 { | 365 { |
368 AdblockPlus::FilterPtr filter = engine->Matches(url, contentType, | 366 AdblockPlus::FilterPtr filterPtr = engine->Matches(url, contentType, documen
tUrls); |
369 documentUrls); | |
370 | 367 |
371 return NewJniFilter(env, filter); | 368 return (filterPtr.get() ? NewJniFilter(env, std::move(*filterPtr)) : 0); |
372 } | 369 } |
373 CATCH_THROW_AND_RETURN(env, 0) | 370 CATCH_THROW_AND_RETURN(env, 0) |
374 } | 371 } |
375 | 372 |
376 static jboolean JNICALL JniIsDocumentWhitelisted(JNIEnv* env, jclass clazz, jlon
g ptr, | 373 static jboolean JNICALL JniIsDocumentWhitelisted(JNIEnv* env, jclass clazz, jlon
g ptr, |
377 jstring jUrl, jobjectArray jDocumentUrls) | 374 jstring jUrl, jobjectArray jDocumentUrls) |
378 { | 375 { |
379 AdblockPlus::FilterEnginePtr& engine = | 376 AdblockPlus::FilterEnginePtr& engine = |
380 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); | 377 *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); |
381 | 378 |
(...skipping 26 matching lines...) Expand all Loading... |
408 } | 405 } |
409 | 406 |
410 static jobject JNICALL JniGetPref(JNIEnv* env, jclass clazz, jlong ptr, jstring
jPref) | 407 static jobject JNICALL JniGetPref(JNIEnv* env, jclass clazz, jlong ptr, jstring
jPref) |
411 { | 408 { |
412 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 409 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
413 | 410 |
414 std::string pref = JniJavaToStdString(env, jPref); | 411 std::string pref = JniJavaToStdString(env, jPref); |
415 | 412 |
416 try | 413 try |
417 { | 414 { |
418 AdblockPlus::JsValuePtr value = engine->GetPref(pref); | 415 return NewJniJsValue(env, engine->GetPref(pref)); |
419 | |
420 return NewJniJsValue(env, value); | |
421 } | 416 } |
422 CATCH_THROW_AND_RETURN(env, 0) | 417 CATCH_THROW_AND_RETURN(env, 0) |
423 } | 418 } |
424 | 419 |
425 static void JNICALL JniSetPref(JNIEnv* env, jclass clazz, jlong ptr, jstring jPr
ef, jlong jsValue) | 420 static void JNICALL JniSetPref(JNIEnv* env, jclass clazz, jlong ptr, jstring jPr
ef, jlong jsValue) |
426 { | 421 { |
427 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); | 422 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn
ginePtr>(ptr); |
428 | 423 |
429 std::string pref = JniJavaToStdString(env, jPref); | 424 std::string pref = JniJavaToStdString(env, jPref); |
430 AdblockPlus::JsValuePtr value = JniGetJsValuePtr(jsValue); | 425 const AdblockPlus::JsValue& value = JniGetJsValue(jsValue); |
431 | 426 |
432 try | 427 try |
433 { | 428 { |
434 engine->SetPref(pref, value); | 429 engine->SetPref(pref, value); |
435 } | 430 } |
436 CATCH_AND_THROW(env) | 431 CATCH_AND_THROW(env) |
437 } | 432 } |
438 | 433 |
439 static jstring JNICALL JniGetHostFromURL(JNIEnv* env, jclass clazz, jlong ptr, j
string jurl) | 434 static jstring JNICALL JniGetHostFromURL(JNIEnv* env, jclass clazz, jlong ptr, j
string jurl) |
440 { | 435 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", (
void*)JniGetHostFromURL }, | 510 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", (
void*)JniGetHostFromURL }, |
516 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J
niSetAllowedConnectionType }, | 511 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J
niSetAllowedConnectionType }, |
517 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn
iGetAllowedConnectionType }, | 512 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn
iGetAllowedConnectionType }, |
518 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 513 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
519 }; | 514 }; |
520 | 515 |
521 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi
ne_registerNatives(JNIEnv *env, jclass clazz) | 516 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi
ne_registerNatives(JNIEnv *env, jclass clazz) |
522 { | 517 { |
523 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 518 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
524 } | 519 } |
OLD | NEW |