Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: libadblockplus-android/jni/JniSubscription.cpp

Issue 29435570: Issue 5205 - Add Subscription.isDisabled() (Closed)
Patch Set: removed casting Created May 22, 2017, 11:33 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 "JniJsValue.h" 20 #include "JniJsValue.h"
21 21
22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr) 22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr)
23 { 23 {
24 return JniLongToTypePtr<AdblockPlus::Subscription>(ptr); 24 return JniLongToTypePtr<AdblockPlus::Subscription>(ptr);
25 } 25 }
26 26
27 static jboolean JNICALL JniIsDisabled(JNIEnv* env, jclass clazz, jlong ptr)
28 {
29 try
30 {
31 return GetSubscriptionPtr(ptr)->IsDisabled() ? JNI_TRUE : JNI_FALSE;
32 }
33 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
34 }
35
36 static void JNICALL JniSetDisabled(JNIEnv* env, jclass clazz, jlong ptr, jboolea n disabled)
37 {
38 try
39 {
40 return GetSubscriptionPtr(ptr)->SetDisabled((bool)(disabled == JNI_TRUE));
41 }
42 CATCH_AND_THROW(env)
43 }
44
27 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr) 45 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr)
28 { 46 {
29 try 47 try
30 { 48 {
31 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE; 49 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE;
32 } 50 }
33 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 51 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
34 } 52 }
35 53
36 static void JNICALL JniAddToList(JNIEnv* env, jclass clazz, jlong ptr) 54 static void JNICALL JniAddToList(JNIEnv* env, jclass clazz, jlong ptr)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 { 103 {
86 try 104 try
87 { 105 {
88 return (GetSubscriptionPtr(ptr)->IsAA() ? JNI_TRUE : JNI_FALSE); 106 return (GetSubscriptionPtr(ptr)->IsAA() ? JNI_TRUE : JNI_FALSE);
89 } 107 }
90 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 108 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
91 } 109 }
92 110
93 static JNINativeMethod methods[] = 111 static JNINativeMethod methods[] =
94 { 112 {
113 { (char*)"isDisabled", (char*)"(J)Z", (void*)JniIsDisabled },
114 { (char*)"setDisabled", (char*)"(JZ)V", (void*)JniSetDisabled },
95 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed }, 115 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed },
96 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList }, 116 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList },
97 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList }, 117 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList },
98 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters }, 118 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters },
99 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating }, 119 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating },
100 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals }, 120 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals },
101 { (char*)"isAcceptableAds", (char*)"(J)Z", (void*)JniIsAcceptableAds }, 121 { (char*)"isAcceptableAds", (char*)"(J)Z", (void*)JniIsAcceptableAds },
102 }; 122 };
103 123
104 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Subscripti on_registerNatives(JNIEnv *env, jclass clazz) 124 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Subscripti on_registerNatives(JNIEnv *env, jclass clazz)
105 { 125 {
106 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 126 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
107 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld