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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 { | 167 { |
168 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 168 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
169 | 169 |
170 try | 170 try |
171 { | 171 { |
172 return SubscriptionsToArrayList(env, engine.FetchAvailableSubscriptions()); | 172 return SubscriptionsToArrayList(env, engine.FetchAvailableSubscriptions()); |
173 } | 173 } |
174 CATCH_THROW_AND_RETURN(env, 0); | 174 CATCH_THROW_AND_RETURN(env, 0); |
175 } | 175 } |
176 | 176 |
177 static void JNICALL JniRemoveUpdateAvailableCallback(JNIEnv* env, jclass clazz, | |
178 jlong ptr) | |
179 { | |
180 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | |
181 try | |
182 { | |
183 engine.RemoveUpdateAvailableCallback(); | |
184 } | |
185 CATCH_AND_THROW(env) | |
186 } | |
187 | |
188 static void JNICALL JniSetUpdateAvailableCallback(JNIEnv* env, jclass clazz, | |
189 jlong ptr, jlong callbackPtr) | |
190 { | |
191 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | |
192 JniUpdateAvailableCallback* const callback = | |
193 JniLongToTypePtr<JniUpdateAvailableCallback>(callbackPtr); | |
194 | |
195 const AdblockPlus::FilterEngine::UpdateAvailableCallback updateAvailableCallba
ck = | |
196 std::bind(&JniUpdateAvailableCallback::Callback, callback, | |
197 std::placeholders::_1); | |
198 try | |
199 { | |
200 engine.SetUpdateAvailableCallback(updateAvailableCallback); | |
201 } | |
202 CATCH_AND_THROW(env) | |
203 } | |
204 | |
205 static void JNICALL JniRemoveFilterChangeCallback(JNIEnv* env, jclass clazz, jlo
ng ptr) | 177 static void JNICALL JniRemoveFilterChangeCallback(JNIEnv* env, jclass clazz, jlo
ng ptr) |
206 { | 178 { |
207 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 179 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
208 | 180 |
209 try | 181 try |
210 { | 182 { |
211 engine.RemoveFilterChangeCallback(); | 183 engine.RemoveFilterChangeCallback(); |
212 } | 184 } |
213 CATCH_AND_THROW(env) | 185 CATCH_AND_THROW(env) |
214 } | 186 } |
(...skipping 10 matching lines...) Expand all Loading... |
225 callback->Callback(arg, std::move(jsValue)); | 197 callback->Callback(arg, std::move(jsValue)); |
226 }; | 198 }; |
227 | 199 |
228 try | 200 try |
229 { | 201 { |
230 engine.SetFilterChangeCallback(filterCallback); | 202 engine.SetFilterChangeCallback(filterCallback); |
231 } | 203 } |
232 CATCH_AND_THROW(env) | 204 CATCH_AND_THROW(env) |
233 } | 205 } |
234 | 206 |
235 static void JNICALL JniForceUpdateCheck(JNIEnv* env, jclass clazz, jlong ptr, jl
ong updaterPtr) | |
236 { | |
237 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | |
238 JniUpdateCheckDoneCallback* callback = | |
239 JniLongToTypePtr<JniUpdateCheckDoneCallback>(updaterPtr); | |
240 | |
241 AdblockPlus::FilterEngine::UpdateCheckDoneCallback | |
242 updateCheckDoneCallback = 0; | |
243 | |
244 if (updaterPtr) | |
245 { | |
246 updateCheckDoneCallback = | |
247 std::bind(&JniUpdateCheckDoneCallback::Callback, callback, | |
248 std::placeholders::_1); | |
249 } | |
250 | |
251 try | |
252 { | |
253 engine.ForceUpdateCheck(updateCheckDoneCallback); | |
254 } | |
255 CATCH_AND_THROW(env) | |
256 } | |
257 | |
258 static jobject JNICALL JniGetElementHidingSelectors(JNIEnv* env, jclass clazz, | 207 static jobject JNICALL JniGetElementHidingSelectors(JNIEnv* env, jclass clazz, |
259 jlong ptr, jstring jDomain) | 208 jlong ptr, jstring jDomain) |
260 { | 209 { |
261 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 210 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
262 | 211 |
263 std::string domain = JniJavaToStdString(env, jDomain); | 212 std::string domain = JniJavaToStdString(env, jDomain); |
264 | 213 |
265 try | 214 try |
266 { | 215 { |
267 std::vector<std::string> selectors = engine.GetElementHidingSelectors( | 216 std::vector<std::string> selectors = engine.GetElementHidingSelectors( |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 { | 462 { |
514 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, | 463 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, |
515 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni
GetFilter }, | 464 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni
GetFilter }, |
516 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed
Filters }, | 465 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed
Filters }, |
517 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription")
, (void*)JniGetSubscription }, | 466 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription")
, (void*)JniGetSubscription }, |
518 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh
owNextNotification }, | 467 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh
owNextNotification }, |
519 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif
icationCallback }, | 468 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif
icationCallback }, |
520 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow
NotificationCallback }, | 469 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow
NotificationCallback }, |
521 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet
ListedSubscriptions }, | 470 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet
ListedSubscriptions }, |
522 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J
niFetchAvailableSubscriptions }, | 471 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J
niFetchAvailableSubscriptions }, |
523 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai
lableCallback }, | |
524 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat
eAvailableCallback }, | |
525 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC
allback }, | 472 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC
allback }, |
526 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh
angeCallback }, | 473 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh
angeCallback }, |
527 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, | |
528 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/
List;", (void*)JniGetElementHidingSelectors }, | 474 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/
List;", (void*)JniGetElementHidingSelectors }, |
529 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp
e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches }, | 475 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp
e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches }, |
530 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp
e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany }, | 476 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp
e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany }, |
531 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri
ng;)Z", (void*)JniIsDocumentWhitelisted }, | 477 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri
ng;)Z", (void*)JniIsDocumentWhitelisted }, |
532 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri
ng;)Z", (void*)JniIsElemhideWhitelisted }, | 478 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri
ng;)Z", (void*)JniIsElemhideWhitelisted }, |
533 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG
etPref }, | 479 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG
etPref }, |
534 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, | 480 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, |
535 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", (
void*)JniGetHostFromURL }, | 481 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", (
void*)JniGetHostFromURL }, |
536 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J
niSetAllowedConnectionType }, | 482 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J
niSetAllowedConnectionType }, |
537 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn
iGetAllowedConnectionType }, | 483 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn
iGetAllowedConnectionType }, |
538 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds
Enabled }, | 484 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds
Enabled }, |
539 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna
bled }, | 485 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna
bled }, |
540 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v
oid*)JniGetAcceptableAdsSubscriptionURL }, | 486 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v
oid*)JniGetAcceptableAdsSubscriptionURL }, |
541 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda
teFiltersAsync }, | 487 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda
teFiltersAsync }, |
542 { (char*)"getNativePtr", (char*)"(J)J", (void*)JniGetFilterEngineNativePtr } | 488 { (char*)"getNativePtr", (char*)"(J)J", (void*)JniGetFilterEngineNativePtr } |
543 }; | 489 }; |
544 | 490 |
545 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi
ne_registerNatives(JNIEnv *env, jclass clazz) | 491 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi
ne_registerNatives(JNIEnv *env, jclass clazz) |
546 { | 492 { |
547 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 493 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
548 } | 494 } |
OLD | NEW |